1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-09-20 01:43:35 +00:00
parent b06bcff42d
commit d325d74174
2 changed files with 7 additions and 1 deletions

View file

@ -9962,6 +9962,7 @@ static NODE *
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));

View file

@ -563,7 +563,8 @@ class TestKeywordArguments < Test::Unit::TestCase
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::TestCase
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