ruby-changes:45125
From: nobu <ko1@a...>
Date: Mon, 26 Dec 2016 22:31:07 +0900 (JST)
Subject: [ruby-changes:45125] nobu:r57198 (trunk): parse.y: preserve cmdarg stack
nobu 2016-12-26 22:31:03 +0900 (Mon, 26 Dec 2016) New Revision: 57198 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57198 Log: parse.y: preserve cmdarg stack * parse.y (do_body): preserve cmdarg stack around do/end block. [ruby-core:78837] [Bug #13073] Modified files: trunk/parse.y trunk/test/ruby/test_syntax.rb Index: parse.y =================================================================== --- parse.y (revision 57197) +++ parse.y (revision 57198) @@ -3762,7 +3762,7 @@ brace_body : {$<vars>$ = dyna_push();} https://github.com/ruby/ruby/blob/trunk/parse.y#L3762 ; do_body : {$<vars>$ = dyna_push();} - {$<val>$ = cmdarg_stack >> 1; CMDARG_SET(0);} + {$<val>$ = cmdarg_stack; CMDARG_SET(0);} opt_block_param compstmt { $$ = new_do_body($3, $4); Index: test/ruby/test_syntax.rb =================================================================== --- test/ruby/test_syntax.rb (revision 57197) +++ test/ruby/test_syntax.rb (revision 57198) @@ -917,6 +917,15 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L917 end end + def test_do_block_in_hash_brace + bug13073 = '[ruby-core:78837] [Bug #13073]' + assert_valid_syntax 'p :foo, {a: proc do end, b: proc do end}', bug13073 + assert_valid_syntax 'p :foo, {:a => proc do end, b: proc do end}', bug13073 + assert_valid_syntax 'p :foo, {"a": proc do end, b: proc do end}', bug13073 + assert_valid_syntax 'p :foo, {** proc do end, b: proc do end}', bug13073 + assert_valid_syntax 'p :foo, {proc do end => proc do end, b: proc do end}', bug13073 + end + def test_do_after_local_variable obj = Object.new def obj.m; yield; end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/