[前][次][番号順一覧][スレッド一覧]

ruby-changes:48498

From: nobu <ko1@a...>
Date: Thu, 2 Nov 2017 16:52:53 +0900 (JST)
Subject: [ruby-changes:48498] nobu:r60613 (trunk): compile.c: kw splat after splat

nobu	2017-11-02 16:52:49 +0900 (Thu, 02 Nov 2017)

  New Revision: 60613

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60613

  Log:
    compile.c: kw splat after splat
    
    * compile.c (setup_args): set keyword splat flag after splat
      arguments.  [ruby-core:83638] [Bug #10856]

  Modified files:
    trunk/compile.c
    trunk/test/ruby/test_keyword.rb
Index: compile.c
===================================================================
--- compile.c	(revision 60612)
+++ compile.c	(revision 60613)
@@ -4197,6 +4197,8 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR https://github.com/ruby/ruby/blob/trunk/compile.c#L4197
 	    INSERT_LIST(args_splat, tmp);
 	    nsplat++;
 	    *flag |= VM_CALL_ARGS_SPLAT;
+	    if (nd_type(argn->nd_body) == NODE_HASH)
+		*flag |= VM_CALL_KW_SPLAT;
 
 	    if (next_is_array) {
 		int len = compile_array(iseq, args, argn->nd_head, COMPILE_ARRAY_TYPE_ARGS, NULL, flag, FALSE);
Index: test/ruby/test_keyword.rb
===================================================================
--- test/ruby/test_keyword.rb	(revision 60612)
+++ test/ruby/test_keyword.rb	(revision 60613)
@@ -513,11 +513,17 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L513
     }
     o = {}
     assert_equal(:ok, m.f(**o), '[ruby-core:68124] [Bug #10856]')
+    a = []
+    assert_equal(:ok, m.f(*a, **o), '[ruby-core:83638] [Bug #10856]')
 
     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]')
+
+    o = {}
+    a = [:ok]
+    assert_equal(:ok, m.f2(*a, **o), '[ruby-core:83638] [Bug #10856]')
   end
 
   def test_gced_object_in_stack

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]