ruby-changes:47440
From: nobu <ko1@a...>
Date: Thu, 10 Aug 2017 09:51:06 +0900 (JST)
Subject: [ruby-changes:47440] nobu:r59556 (trunk): compile.c: fix KW_SPLAT flag condition
nobu 2017-08-10 09:50:45 +0900 (Thu, 10 Aug 2017) New Revision: 59556 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59556 Log: 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] Modified files: trunk/compile.c trunk/test/ruby/test_keyword.rb Index: test/ruby/test_keyword.rb =================================================================== --- test/ruby/test_keyword.rb (revision 59555) +++ test/ruby/test_keyword.rb (revision 59556) @@ -516,6 +516,8 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L516 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 Index: compile.c =================================================================== --- compile.c (revision 59555) +++ compile.c (revision 59556) @@ -3052,11 +3052,14 @@ compile_array_keyword_arg(rb_iseq_t *ise https://github.com/ruby/ruby/blob/trunk/compile.c#L3052 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 */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/