ruby-changes:41063
From: nobu <ko1@a...>
Date: Wed, 16 Dec 2015 10:50:07 +0900 (JST)
Subject: [ruby-changes:41063] nobu:r53138 (trunk): parse.y: fix block_call&.call
nobu 2015-12-16 10:49:42 +0900 (Wed, 16 Dec 2015) New Revision: 53138 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53138 Log: parse.y: fix block_call&.call * parse.y (block_command, block_call): fix `&.` calls after block_call. [Feature #11537] Modified files: trunk/ChangeLog trunk/parse.y trunk/test/ruby/test_call.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 53137) +++ ChangeLog (revision 53138) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Dec 16 10:49:51 2015 Nobuyoshi Nakada <nobu@r...> + + * parse.y (block_command, block_call): fix `&.` calls after + block_call. [Feature #11537] + Wed Dec 16 00:53:45 2015 Naohisa Goto <ngotogenome@g...> * lib/webrick/utils.rb (WEBrick::Utils::TimeoutHandler): Acquire Index: parse.y =================================================================== --- parse.y (revision 53137) +++ parse.y (revision 53138) @@ -1413,7 +1413,7 @@ block_command : block_call https://github.com/ruby/ruby/blob/trunk/parse.y#L1413 | block_call call_op2 operation2 command_args { /*%%%*/ - $$ = NEW_CALL($1, $3, $4); + $$ = NEW_QCALL($2, $1, $3, $4); /*% $$ = dispatch3(call, $1, $2, $3); $$ = method_arg($$, $4); @@ -3626,7 +3626,7 @@ block_call : command do_block https://github.com/ruby/ruby/blob/trunk/parse.y#L3626 | block_call call_op2 operation2 opt_paren_args { /*%%%*/ - $$ = NEW_CALL($1, $3, $4); + $$ = NEW_QCALL($2, $1, $3, $4); /*% $$ = dispatch3(call, $1, $2, $3); $$ = method_optarg($$, $4); @@ -3636,7 +3636,7 @@ block_call : command do_block https://github.com/ruby/ruby/blob/trunk/parse.y#L3636 { /*%%%*/ block_dup_check($4, $5); - $5->nd_iter = NEW_CALL($1, $3, $4); + $5->nd_iter = NEW_QCALL($2, $1, $3, $4); $$ = $5; fixpos($$, $1); /*% @@ -3648,7 +3648,7 @@ block_call : command do_block https://github.com/ruby/ruby/blob/trunk/parse.y#L3648 { /*%%%*/ block_dup_check($4, $5); - $5->nd_iter = NEW_CALL($1, $3, $4); + $5->nd_iter = NEW_QCALL($2, $1, $3, $4); $$ = $5; fixpos($$, $1); /*% Index: test/ruby/test_call.rb =================================================================== --- test/ruby/test_call.rb (revision 53137) +++ test/ruby/test_call.rb (revision 53138) @@ -65,4 +65,21 @@ class TestCall < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_call.rb#L65 o.x&.at(proc.call) assert_equal(1, count) end + + def test_safe_call_block_command + assert_nil(("a".sub! "b" do end&.foo 1)) + end + + def test_safe_call_block_call + assert_nil(("a".sub! "b" do end&.foo)) + end + + def test_safe_call_block_call_brace + assert_nil(("a".sub! "b" do end&.foo {})) + assert_nil(("a".sub! "b" do end&.foo do end)) + end + + def test_safe_call_block_call_command + assert_nil(("a".sub! "b" do end&.foo 1 do end)) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/