diff --git a/ChangeLog b/ChangeLog index 153c762d55..54e5d388c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Apr 30 16:22:16 2015 Nobuyoshi Nakada + + * parse.y (lambda): push and reset cmdarg_stack in lambda body. + [ruby-core:69017] [Bug #11107] + Sun Apr 26 07:36:48 2015 Nobuyoshi Nakada * enc/utf_8.c (code_to_mbclen, code_to_mbc): reject values larger diff --git a/parse.y b/parse.y index f80f7d926f..75b3d48213 100644 --- a/parse.y +++ b/parse.y @@ -3518,14 +3518,19 @@ lambda : { { $$ = ruby_sourceline; } + { + $$ = cmdarg_stack; + cmdarg_stack = 0; + } lambda_body { lpar_beg = $2; + cmdarg_stack = $5; /*%%%*/ - $$ = NEW_LAMBDA($3, $5); + $$ = NEW_LAMBDA($3, $6); nd_set_line($$, $4); /*% - $$ = dispatch2(lambda, $3, $5); + $$ = dispatch2(lambda, $3, $6); %*/ dyna_pop($1); } diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 0274a11e83..dbb18164f4 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -400,6 +400,11 @@ WARN assert_valid_syntax("bar def foo; self.each do end end", bug9308) end + def test_do_block_in_lambda + bug11107 = '[ruby-core:69017] [Bug #11107]' + assert_valid_syntax('p ->() do a() do end end', bug11107) + end + def test_reserved_method_no_args bug6403 = '[ruby-dev:45626]' assert_valid_syntax("def self; :foo; end", __FILE__, bug6403)