diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | test/ruby/test_super.rb | 23 | ||||
-rw-r--r-- | vm_insnhelper.c | 2 |
3 files changed, 33 insertions, 1 deletions
@@ -1,3 +1,12 @@ +Tue Sep 3 03:17:26 2013 Koichi Sasada <ko1@atdot.net> + + * 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@iDaemons.org> * numeric.c (num_step): Default the limit argument to infinity and diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb index 98cf43b7a1..1aab553ebb 100644 --- a/test/ruby/test_super.rb +++ b/test/ruby/test_super.rb @@ -385,4 +385,27 @@ class TestSuper < Test::Unit::TestCase 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 diff --git a/vm_insnhelper.c b/vm_insnhelper.c index f196e5dc2d..fa7791e38a 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2016,7 +2016,7 @@ vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf { 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)) { |