ruby-changes:52574
From: nobu <ko1@a...>
Date: Thu, 20 Sep 2018 10:43:41 +0900 (JST)
Subject: [ruby-changes:52574] nobu:r64786 (trunk): parse.y: fix block passing with empty kwargs
nobu 2018-09-20 10:43:35 +0900 (Thu, 20 Sep 2018) New Revision: 64786 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64786 Log: parse.y: fix block passing with empty kwargs * parse.y (arg_blk_pass): preceeding arguments node may be NULL when an empty keyword argument hash splat is optimized away. [ruby-core:88890] [Bug #15087] Modified files: trunk/parse.y trunk/test/ruby/test_keyword.rb Index: parse.y =================================================================== --- parse.y (revision 64785) +++ parse.y (revision 64786) @@ -9962,6 +9962,7 @@ static NODE * https://github.com/ruby/ruby/blob/trunk/parse.y#L9962 arg_blk_pass(NODE *node1, NODE *node2) { if (node2) { + if (!node1) return node2; node2->nd_head = node1; nd_set_first_lineno(node2, nd_first_lineno(node1)); nd_set_first_column(node2, nd_first_column(node1)); Index: test/ruby/test_keyword.rb =================================================================== --- test/ruby/test_keyword.rb (revision 64785) +++ test/ruby/test_keyword.rb (revision 64786) @@ -563,7 +563,8 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L563 def test_dynamic_symbol_keyword bug10266 = '[ruby-dev:48564] [Bug #10266]' - assert_separately(['-', bug10266], <<-'end;') # do + assert_separately(['-', bug10266], "#{<<~"begin;"}\n#{<<~'end;'}") + begin; bug = ARGV.shift "hoge".to_sym assert_nothing_raised(bug) {eval("def a(hoge:); end")} @@ -746,4 +747,8 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L747 assert_equal(:ok, many_kwargs(e0: :ok)[i], "#{i}: e0"); i+=1 end + + def test_splat_empty_hash_with_block_passing + assert_valid_syntax("bug15087(**{}, &nil)") + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/