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

ruby-changes:28755

From: nobu <ko1@a...>
Date: Sat, 18 May 2013 16:39:06 +0900 (JST)
Subject: [ruby-changes:28755] nobu:r40807 (trunk): compile.c: forward kwrest

nobu	2013-05-18 16:38:55 +0900 (Sat, 18 May 2013)

  New Revision: 40807

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40807

  Log:
    compile.c: forward kwrest
    
    * compile.c (iseq_compile_each): forward anonymous and first keyword
      rest argument one.  [ruby-core:55033] [Bug #8416].

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
    trunk/test/ruby/test_keyword.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40806)
+++ ChangeLog	(revision 40807)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat May 18 16:38:39 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* compile.c (iseq_compile_each): forward anonymous and first keyword
+	  rest argument one.  [ruby-core:55033] [Bug #8416].
+
 Sat May 18 15:49:14 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* vm_core.h (rb_vm_tag): move jmpbuf between tag and prev so ensure to
Index: compile.c
===================================================================
--- compile.c	(revision 40806)
+++ compile.c	(revision 40807)
@@ -4485,7 +4485,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L4485
 		    }
 		}
 
-		if (liseq->arg_keyword > 0) {
+		if (liseq->arg_keyword >= 0) {
 		    int local_size = liseq->local_size;
 		    int idx = local_size - liseq->arg_keyword;
 		    argc++;
Index: test/ruby/test_keyword.rb
===================================================================
--- test/ruby/test_keyword.rb	(revision 40806)
+++ test/ruby/test_keyword.rb	(revision 40807)
@@ -349,4 +349,34 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L349
     assert_equal([42, {:bar=>"x"}], a.new.foo(42), bug8236)
     assert_equal([42, {:bar=>"x"}], b.new.foo(42), bug8236)
   end
+
+  def test_zsuper_only_named_kwrest
+    bug8416 = '[ruby-core:55033] [Bug #8416]'
+    base = Class.new do
+      def foo(**h)
+        h
+      end
+    end
+    a = Class.new(base) do
+      def foo(**h)
+        super
+      end
+    end
+    assert_equal({:bar=>"x"}, a.new.foo(bar: "x"), bug8416)
+  end
+
+  def test_zsuper_only_anonymous_kwrest
+    bug8416 = '[ruby-core:55033] [Bug #8416]'
+    base = Class.new do
+      def foo(**h)
+        h
+      end
+    end
+    a = Class.new(base) do
+      def foo(**)
+        super
+      end
+    end
+    assert_equal({:bar=>"x"}, a.new.foo(bar: "x"), bug8416)
+  end
 end

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

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