mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
d9beb7690f
commit
4493657582
2 changed files with 18 additions and 0 deletions
|
@ -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) {
|
if (liseq->body->param.flags.has_rest) {
|
||||||
/* rest argument */
|
/* rest argument */
|
||||||
int idx = liseq->body->local_table_size - liseq->body->param.rest_start;
|
int idx = liseq->body->local_table_size - liseq->body->param.rest_start;
|
||||||
|
|
||||||
ADD_GETLOCAL(args, line, idx, lvar_level);
|
ADD_GETLOCAL(args, line, idx, lvar_level);
|
||||||
|
ADD_INSN1(args, line, splatarray, Qfalse);
|
||||||
|
|
||||||
argc = liseq->body->param.rest_start + 1;
|
argc = liseq->body->param.rest_start + 1;
|
||||||
flag |= VM_CALL_ARGS_SPLAT;
|
flag |= VM_CALL_ARGS_SPLAT;
|
||||||
|
|
|
@ -544,4 +544,20 @@ class TestSuper < Test::Unit::TestCase
|
||||||
c.new
|
c.new
|
||||||
}
|
}
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue