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

ruby-changes:49488

From: ko1 <ko1@a...>
Date: Fri, 5 Jan 2018 11:25:30 +0900 (JST)
Subject: [ruby-changes:49488] ko1:r61603 (trunk): check array for zsuper. [Bug #14279]

ko1	2018-01-05 11:25:26 +0900 (Fri, 05 Jan 2018)

  New Revision: 61603

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

  Log:
    check array for zsuper. [Bug #14279]
    
    * compile.c (iseq_compile_each0): for zsuper (NODE_ZSUPER), we need to check
      given argument is Array or not.
    
    * test/ruby/test_super.rb: add a test for this bug.

  Modified files:
    trunk/compile.c
    trunk/test/ruby/test_super.rb
Index: compile.c
===================================================================
--- compile.c	(revision 61602)
+++ compile.c	(revision 61603)
@@ -6221,7 +6221,9 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK https://github.com/ruby/ruby/blob/trunk/compile.c#L6221
 	    if (liseq->body->param.flags.has_rest) {
 		/* rest argument */
 		int idx = liseq->body->local_table_size - liseq->body->param.rest_start;
+
 		ADD_GETLOCAL(args, line, idx, lvar_level);
+		ADD_INSN1(args, line, splatarray, Qfalse);
 
 		argc = liseq->body->param.rest_start + 1;
 		flag |= VM_CALL_ARGS_SPLAT;
Index: test/ruby/test_super.rb
===================================================================
--- test/ruby/test_super.rb	(revision 61602)
+++ test/ruby/test_super.rb	(revision 61603)
@@ -544,4 +544,20 @@ class TestSuper < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_super.rb#L544
       c.new
     }
   end
+
+  class TestFor_super_with_modified_rest_parameter_base
+    def foo *args
+      args
+    end
+  end
+
+  class TestFor_super_with_modified_rest_parameter < TestFor_super_with_modified_rest_parameter_base
+    def foo *args
+      args = 13
+      super
+    end
+  end
+  def test_super_with_modified_rest_parameter
+    assert_equal [13], TestFor_super_with_modified_rest_parameter.new.foo
+  end
 end

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

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