Project

General

Profile

Bug #11833

2.2.4 syntax error when naked percent notation touches keyword arguments

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

Status:
Closed
Priority:
Normal
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

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

Associated revisions

Revision 3b3500c6
Added by nagachika (Tomoyuki Chikanaga) almost 4 years ago

merge revision(s) 53092,53093: [Backport #11812] [Backport #11833]

    * parse.y (parse_percent): Allow %-literals in labeled arg as
      r51624 did for parentheses.
      Fixes [ruby-core:72084] [Bug #11812].

    * test/ruby/test_syntax.rb: fix typo in test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@53257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 53257
Added by nagachika (Tomoyuki Chikanaga) almost 4 years ago

merge revision(s) 53092,53093: [Backport #11812] [Backport #11833]

* parse.y (parse_percent): Allow %-literals in labeled arg as
  r51624 did for parentheses.
  Fixes [ruby-core:72084] [Bug #11812].

* test/ruby/test_syntax.rb: fix typo in test

History

#1

Updated by yui-knk (Kaneko Yuichiro) almost 4 years ago

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

Updated by yui-knk (Kaneko Yuichiro) almost 4 years ago

I think backport of #11812 to ruby 2.2 is required.

#3

Updated by nagachika (Tomoyuki Chikanaga) almost 4 years ago

  • Status changed from Open to Closed

Applied in changeset backport22:r53257.


merge revision(s) 53092,53093: [Backport #11812] [Backport #11833]

* parse.y (parse_percent): Allow %-literals in labeled arg as
  r51624 did for parentheses.
  Fixes [ruby-core:72084] [Bug #11812].

* test/ruby/test_syntax.rb: fix typo in test

Updated by nagachika (Tomoyuki Chikanaga) almost 4 years ago

Thank you for your report and notice.
I've just backport at r53257.

Are there any concrete gems which is affected by this regression?
I want to know the severity of this issue in the real world.

#5

Updated by hsbt (Hiroshi SHIBATA) almost 4 years ago

  • Has duplicate Bug #11914: 2.2.4: Parsing "symbol:%w(word)" gives SyntaxError added

Updated by usa (Usaku NAKAMURA) almost 4 years ago

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

Also available in: Atom PDF