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

compile.c: fix KW_SPLAT flag condition

* compile.c (compile_array_keyword_arg): fix the condition of
  KW_SPLAT flag.  splat is value node only without key node,
  simple assoc argument is not.  [ruby-core:82291] [Bug #13793]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-08-10 00:50:45 +00:00
parent c20fe4313b
commit 059cf260e7
2 changed files with 7 additions and 2 deletions

View file

@ -3052,11 +3052,14 @@ compile_array_keyword_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
NODE *key_node = node->nd_head;
assert(nd_type(node) == NODE_ARRAY);
if (key_node && nd_type(key_node) == NODE_LIT && RB_TYPE_P(key_node->nd_lit, T_SYMBOL)) {
if (!key_node) {
if (flag) *flag |= VM_CALL_KW_SPLAT;
return FALSE;
}
else if (nd_type(key_node) == NODE_LIT && RB_TYPE_P(key_node->nd_lit, T_SYMBOL)) {
/* can be keywords */
}
else {
if (flag) *flag |= VM_CALL_KW_SPLAT;
return FALSE;
}
node = node->nd_next; /* skip value node */

View file

@ -516,6 +516,8 @@ class TestKeywordArguments < Test::Unit::TestCase
o = {a: 42}
assert_equal({a: 42}, m.f2(**o), '[ruby-core:82280] [Bug #13791]')
assert_equal({a: 42}, m.f2("a".to_sym => 42), '[ruby-core:82291] [Bug #13793]')
end
def test_gced_object_in_stack