Project

General

Profile

Bug #11107

Syntax error is raised by "p ->() do a(1) do end end", but not by "p ->() do a 1 do end end"

Added by wanabe (_ wanabe) over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-04-26 trunk 50395) [x86_64-darwin14]
[ruby-core:69017]

Description

As below, lambda literal with do..end block can raise syntax error.

$ ./ruby -ve 'p ->() do a(1) do end end'
ruby 2.3.0dev (2015-04-26 trunk 50395) [x86_64-darwin14]
-e:1: syntax error, unexpected keyword_do_block, expecting keyword_end
p ->() do a(1) do end end
                 ^

The error is not raised when I use {...} block or omit parentheses from method call in lambda.

NG cases:

p ->() do a(1) do end end
p ->() do a() do end end
p 1, ->() do a(1) do end end

OK cases:

p ->() do a 1 do end end
p ->() do a do end end
p ->() { a(1) do end }
p ->() do a(1) {} end
p ->() { a(1) { } }

Confirmed versions (same results):

  • ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-darwin14.3.0]
  • ruby 2.0.0p598 (2014-11-13) [i386-mingw32]
  • ruby 2.1.5p273 (2014-11-13 revision 48405) [i386-mingw32]
  • ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
  • ruby 2.3.0dev (2015-04-26 trunk 50395) [x86_64-darwin14]

Related issues

Related to Ruby master - Bug #11380: Parser regression in 2.3?ClosedActions

Associated revisions

Revision fd0e9d25
Added by nobu (Nobuyoshi Nakada) over 4 years ago

parse.y: push cmdarg_stack

  • parse.y (lambda): push and reset cmdarg_stack in lambda body. [ruby-core:69017] [Bug #11107]

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

Revision 50402
Added by nobu (Nobuyoshi Nakada) over 4 years ago

parse.y: push cmdarg_stack

  • parse.y (lambda): push and reset cmdarg_stack in lambda body. [ruby-core:69017] [Bug #11107]

Revision 50402
Added by nobu (Nobuyoshi Nakada) over 4 years ago

parse.y: push cmdarg_stack

  • parse.y (lambda): push and reset cmdarg_stack in lambda body. [ruby-core:69017] [Bug #11107]

Revision 50402
Added by nobu (Nobuyoshi Nakada) over 4 years ago

parse.y: push cmdarg_stack

  • parse.y (lambda): push and reset cmdarg_stack in lambda body. [ruby-core:69017] [Bug #11107]

Revision 50402
Added by nobu (Nobuyoshi Nakada) over 4 years ago

parse.y: push cmdarg_stack

  • parse.y (lambda): push and reset cmdarg_stack in lambda body. [ruby-core:69017] [Bug #11107]

Revision 50402
Added by nobu (Nobuyoshi Nakada) over 4 years ago

parse.y: push cmdarg_stack

  • parse.y (lambda): push and reset cmdarg_stack in lambda body. [ruby-core:69017] [Bug #11107]

Revision 4a680e81
Added by usa (Usaku NAKAMURA) over 4 years ago

merge revision(s) 50402: [Backport #11107]

    * parse.y (lambda): push and reset cmdarg_stack in lambda body.
      [ruby-core:69017] [Bug #11107]

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

Revision 50468
Added by usa (Usaku NAKAMURA) over 4 years ago

merge revision(s) 50402: [Backport #11107]

* parse.y (lambda): push and reset cmdarg_stack in lambda body.
  [ruby-core:69017] [Bug #11107]

Revision 3dd4b241
Added by nagachika (Tomoyuki Chikanaga) over 4 years ago

merge revision(s) 50402: [Backport #11107]

    * parse.y (lambda): push and reset cmdarg_stack in lambda body.
      [ruby-core:69017] [Bug #11107]

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

Revision 50487
Added by nagachika (Tomoyuki Chikanaga) over 4 years ago

merge revision(s) 50402: [Backport #11107]

* parse.y (lambda): push and reset cmdarg_stack in lambda body.
  [ruby-core:69017] [Bug #11107]

History

#1

Updated by nobu (Nobuyoshi Nakada) over 4 years ago

  • Status changed from Open to Closed

Applied in changeset r50402.


parse.y: push cmdarg_stack

  • parse.y (lambda): push and reset cmdarg_stack in lambda body. [ruby-core:69017] [Bug #11107]

Updated by nobu (Nobuyoshi Nakada) over 4 years ago

  • Description updated (diff)
  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED

Updated by usa (Usaku NAKAMURA) over 4 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED to 2.0.0: REQUIRED, 2.1: DONE, 2.2: REQUIRED

ruby_2_1 r50468 merged revision(s) 50402.

Updated by nagachika (Tomoyuki Chikanaga) over 4 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: DONE, 2.2: REQUIRED to 2.0.0: REQUIRED, 2.1: DONE, 2.2: DONE

Backported into ruby_2_2 branch at r50487.

#5

Updated by nobu (Nobuyoshi Nakada) about 4 years ago

  • Related to Bug #11380: Parser regression in 2.3? added

Also available in: Atom PDF