Actions
Bug #12200
closedMRI 2.2.4 parser forces blanks for hash keys which point to an array literal
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-darwin15]
Backport:
Description
In MRI 2.2.3 and below this was valid code:
$ ruby -v -e 'a={ name:%w(a b c) }; puts a'
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]
{:name=>["a", "b", "c"]}
In MRI 2.2.4 the same code will generate a syntax error:
$ ruby -v -e 'a={ name:%w(a b c) }; puts a'
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-darwin15]
-e:1: syntax error, unexpected '%'
a={ name:%w(a b c)}; puts a
^
-e:1: syntax error, unexpected '}', expecting end-of-input
a={ name:%w(a b c)}; puts a
^
However, adding a blank between the : and the % fixes the error:
$ ruby -v -e 'a={ name: %w(a b c) }; puts a'
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-darwin15]
{:name=>["a", "b", "c"]}
Is this the intended behavior? Regards
Christian
Actions
Like0
Like0Like0Like0