Bug #11604
closedRuby's interpreting hash symbol keys as parts of Ruby syntax
Description
Cannot initialize hashes with some Ruby reserved keywords like: while, until, if, unless, do. Can with other like class, end, elsif, super. Don't really get why
However when assigned, works perfectly
But when used as a method argument - fails
Works with old syntax
And with new but with quotation marks
Example file included. Please just execute like this:
Files
Updated by shugo (Shugo Maeda) almost 11 years ago
- Status changed from Open to Feedback
Maciej Mensfeld wrote:
Cannot initialize hashes with some Ruby reserved keywords like: while, until, if, unless, do. Can with other like class, end, elsif, super. Don't really get why
These syntax errors are not caused by key names, but by the use of { just after the method names.
The following code also causes a syntax error without the new style syntax of hash literals:
In this case, { is not interpreted as the beginning of a hash literal, but the beginning of a block, and thus a syntax error occurs.
Updated by maciej.mensfeld (Maciej Mensfeld) almost 11 years ago
That is true but IMHO it should still be considered as a bug.
Updated by nobu (Nobuyoshi Nakada) almost 11 years ago
- Status changed from Feedback to Rejected
Yes, it's your bug.