Actions
Bug #16050
closed:@ is not parsed correctly
Bug #16050:
:@ is not parsed correctly
Description
Symbol literal allows @ as the first character:
:@foo # => :@foo
Nevertheless, it does not allow @ by itself:
:@ # >> SyntaxError: `@' without identifiers is not allowed as an instance variable name
This resembles #10463, but while #10463 is related to placeholder in a method name, the issue here is related to instance variable name, so I think they are different issues.
Updated by jeremyevans0 (Jeremy Evans) about 6 years ago
- Status changed from Open to Rejected
I don't think this is a bug. Just because :@iv is valid syntax does not imply that :@ should also be valid syntax. You should use a quoted symbol (note that Symbol#inspect quotes the symbol):
:'@'
# => :"@"
'@'.to_sym
# => :"@"
Updated by Dan0042 (Daniel DeLorme) about 6 years ago
Ah, but :@1 is not parsed either, even though it's now (unfortunately) valid as a numbered block parameter.
Depending on how #15723 goes, :@1 and/or :@ should be parsed if they are valid identifiers.
Actions