Project

General

Profile

Actions

Bug #11833

closed

2.2.4 syntax error when naked percent notation touches keyword arguments

Added by cjcsuhta (Corey Csuhta) almost 9 years ago. Updated almost 9 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:72219]

Description

Possible regression:

In Ruby 2.2.3, naked percent-notation was allowed in keyword arguments without spacing, like this:

$ ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]

$ ruby -e "def foo(x:%i[a b c]); puts x end; foo"
a
b
c

In Ruby 2.2.4 this is a syntax error:

$ ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-darwin15]

$ ruby -e "def foo(x:%i[a b c]); puts x end; foo"
-e:1: syntax error, unexpected '%', expecting ')'
def foo(x:%i[a b c]); puts x end; foo
           ^
-e:1: syntax error, unexpected ')', expecting end-of-input
def foo(x:%i[a b c]); puts x end; foo

This however works:

$ ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-darwin15]

$ ruby -e "def foo(x: %i[a b c]); puts x end; foo"
a
b
c

Notice the extra space after x:


Related issues 2 (0 open2 closed)

Related to Ruby master - Bug #11812: Lack of space between colon and % literal causes syntax errorClosedActions
Has duplicate Ruby master - Bug #11914: 2.2.4: Parsing "symbol:%w(word)" gives SyntaxErrorClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0