* [ruby-core:101984] [Ruby master Bug#17520] Allow symbols starting with number, e.g. :2_weeks
@ 2021-01-08 21:59 dorian
2021-01-08 22:41 ` [ruby-core:101985] " marcandre-ruby-core
0 siblings, 1 reply; 2+ messages in thread
From: dorian @ 2021-01-08 21:59 UTC (permalink / raw)
To: ruby-core
Issue #17520 has been reported by dorianmariefr (Dorian Marié).
----------------------------------------
Bug #17520: Allow symbols starting with number, e.g. :2_weeks
https://bugs.ruby-lang.org/issues/17520
* Author: dorianmariefr (Dorian Marié)
* Status: Open
* Priority: Normal
* ruby -v: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
For instance:
```
p({ 2_weeks: 1 })
```
results in:
```
a.rb:1: trailing `_' in number
p({ 2_weeks: 1 })
a.rb:1: syntax error, unexpected local variable or method, expecting =>
p({ 2_weeks: 1 })
```
and
```
p({ :2_weeks => 1 })
```
results in:
```
a.rb:1: trailing `_' in number
p({ :2_weeks => 1 })
a.rb:1: syntax error, unexpected integer literal, expecting literal content or terminator or tSTRING_DBEG or tSTRING_DVAR
```
I'm not sure if it's doable as ruby thinks I'm writing a number, just wondering if that could be possible to start a symbol with a number
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
^ permalink raw reply [flat|nested] 2+ messages in thread
* [ruby-core:101985] [Ruby master Bug#17520] Allow symbols starting with number, e.g. :2_weeks
2021-01-08 21:59 [ruby-core:101984] [Ruby master Bug#17520] Allow symbols starting with number, e.g. :2_weeks dorian
@ 2021-01-08 22:41 ` marcandre-ruby-core
0 siblings, 0 replies; 2+ messages in thread
From: marcandre-ruby-core @ 2021-01-08 22:41 UTC (permalink / raw)
To: ruby-core
Issue #17520 has been updated by marcandre (Marc-Andre Lafortune).
Status changed from Open to Feedback
You may not know that:
```ruby
p({ '2_weeks': 1 })
# => prints {:"2_weeks"=>1}
```
Such symbols being quite rare, I believe this solution should be enough.
----------------------------------------
Bug #17520: Allow symbols starting with number, e.g. :2_weeks
https://bugs.ruby-lang.org/issues/17520#change-89836
* Author: dorianmariefr (Dorian Marié)
* Status: Feedback
* Priority: Normal
* ruby -v: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
For instance:
```
p({ 2_weeks: 1 })
```
results in:
```
a.rb:1: trailing `_' in number
p({ 2_weeks: 1 })
a.rb:1: syntax error, unexpected local variable or method, expecting =>
p({ 2_weeks: 1 })
```
and
```
p({ :2_weeks => 1 })
```
results in:
```
a.rb:1: trailing `_' in number
p({ :2_weeks => 1 })
a.rb:1: syntax error, unexpected integer literal, expecting literal content or terminator or tSTRING_DBEG or tSTRING_DVAR
```
I'm not sure if it's doable as ruby thinks I'm writing a number, just wondering if that could be possible to start a symbol with a number
(I know `{ "2_weeks": 1 }` works, that's what I'm using instead)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-08 22:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-08 21:59 [ruby-core:101984] [Ruby master Bug#17520] Allow symbols starting with number, e.g. :2_weeks dorian
2021-01-08 22:41 ` [ruby-core:101985] " marcandre-ruby-core
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).