[ruby-core:74522] [Ruby trunk Bug#12200] MRI 2.2.4 parser forces blanks for hash keys which point to an array literal

From: usa@...
Date: 2016-03-24 07:53:52 UTC
List: ruby-core #74522
Issue #12200 has been updated by Usaku NAKAMURA.

Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: DONTNEED, 2.2: DONE

----------------------------------------
Bug #12200: MRI 2.2.4 parser forces blanks for hash keys which point to an array literal
https://bugs.ruby-lang.org/issues/12200#change-57646

* Author: Christian Aust
* Status: Closed
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-darwin15]
* Backport: 2.1: DONTNEED, 2.2: DONE
----------------------------------------
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



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next