summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-05 02:25:26 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-05 02:25:26 +0000
commit4493657582d1dfd203f7b6c02d7006094242e525 (patch)
tree905a49a4a5cbde574d66418b89c0ddd861ff795a
parentd9beb7690fb88734de52c67ab030cf0f864a2762 (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--compile.c2
-rw-r--r--test/ruby/test_super.rb16
2 files changed, 18 insertions, 0 deletions
diff --git a/compile.c b/compile.c
index 94b5daeec0..7c1c359b22 100644
--- a/compile.c
+++ b/compile.c
@@ -6221,7 +6221,9 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
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;
diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb
index 9691116fb4..cf7580ab00 100644
--- a/test/ruby/test_super.rb
+++ b/test/ruby/test_super.rb
@@ -544,4 +544,20 @@ class TestSuper < Test::Unit::TestCase
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