Project

General

Profile

Actions

Bug #12200

closed

MRI 2.2.4 parser forces blanks for hash keys which point to an array literal

Added by datenimperator (Christian Aust) over 8 years ago. Updated over 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-darwin15]
[ruby-core:74471]

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


Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Bug #11812: Lack of space between colon and % literal causes syntax errorClosedActions
Actions #1

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Is duplicate of Bug #11812: Lack of space between colon and % literal causes syntax error added

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Status changed from Open to Closed

Updated by usa (Usaku NAKAMURA) over 8 years ago

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

Also available in: Atom PDF

Like0
Like0Like0Like0