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

ruby-changes:30703

From: ko1 <ko1@a...>
Date: Tue, 3 Sep 2013 03:21:24 +0900 (JST)
Subject: [ruby-changes:30703] ko1:r42782 (trunk): * vm_insnhelper.c (vm_search_super_method): use ci->argc instead of

ko1	2013-09-03 03:21:13 +0900 (Tue, 03 Sep 2013)

  New Revision: 42782

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

  Log:
    * vm_insnhelper.c (vm_search_super_method): use ci->argc instead of
      ci->orig_argc. ci->argc can be changed by splat arguments.
      [ruby-list:49575]
      This fix should be applied to Ruby 2.0.0 seriese.
    * test/ruby/test_super.rb: add a test for above.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_super.rb
    trunk/vm_insnhelper.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42781)
+++ ChangeLog	(revision 42782)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Sep  3 03:17:26 2013  Koichi Sasada  <ko1@a...>
+
+	* vm_insnhelper.c (vm_search_super_method): use ci->argc instead of
+	  ci->orig_argc. ci->argc can be changed by splat arguments.
+	  [ruby-list:49575]
+	  This fix should be applied to Ruby 2.0.0 seriese.
+
+	* test/ruby/test_super.rb: add a test for above.
+
 Mon Sep  2 23:46:29 2013  Akinori MUSHA  <knu@i...>
 
 	* numeric.c (num_step): Default the limit argument to infinity and
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 42781)
+++ vm_insnhelper.c	(revision 42782)
@@ -2016,7 +2016,7 @@ vm_search_super_method(rb_thread_t *th, https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2016
 {
     VALUE current_defined_class;
     rb_iseq_t *iseq = GET_ISEQ();
-    VALUE sigval = TOPN(ci->orig_argc);
+    VALUE sigval = TOPN(ci->argc);
 
     current_defined_class = GET_CFP()->klass;
     if (NIL_P(current_defined_class)) {
Index: test/ruby/test_super.rb
===================================================================
--- test/ruby/test_super.rb	(revision 42781)
+++ test/ruby/test_super.rb	(revision 42782)
@@ -385,4 +385,27 @@ class TestSuper < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_super.rb#L385
   def test_super_in_BEGIN
     assert_super_in_block("BEGIN")
   end
+
+  class X
+    def foo(*args)
+      args
+    end
+  end
+
+  class Y < X
+    define_method(:foo) do |*args|
+      super(*args)
+    end
+  end
+
+  def test_super_splat
+    # [ruby-list:49575] 
+    y = Y.new
+    assert_equal([1, 2], y.foo(1, 2))
+    assert_equal([1, false], y.foo(1, false))
+    assert_equal([1, 2, 3, 4, 5], y.foo(1, 2, 3, 4, 5))
+    assert_equal([false, true], y.foo(false, true))
+    assert_equal([false, false], y.foo(false, false))
+    assert_equal([1, 2, 3, false, 5], y.foo(1, 2, 3, false, 5))
+  end
 end

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

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