merge revision(s) 61603: [Backport #14279]

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/branches/ruby_2_3@62944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2018-03-28 05:46:13 +00:00
parent 08987d3105
commit 0b46bbf76d
4 changed files with 29 additions and 1 deletions

View file

@ -1,3 +1,12 @@
Mon Mar 28 14:45:02 2018 Koichi Sasada <ko1@atdot.net>
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.
Sun Mar 28 14:40:25 2018 Eric Wong <normalperson@yhbt.net>
net/ftp: fix FrozenError in BufferedSocket

View file

@ -5074,7 +5074,10 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
if (liseq->body->param.flags.has_rest) {
/* rest argument */
int idx = liseq->body->local_size - liseq->body->param.rest_start;
ADD_INSN2(args, line, getlocal, INT2FIX(idx), INT2FIX(lvar_level));
ADD_INSN1(args, line, splatarray, Qfalse);
argc = liseq->body->param.rest_start + 1;
flag |= VM_CALL_ARGS_SPLAT;
}

View file

@ -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

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.3.7"
#define RUBY_RELEASE_DATE "2018-03-28"
#define RUBY_PATCHLEVEL 440
#define RUBY_PATCHLEVEL 441
#define RUBY_RELEASE_YEAR 2018
#define RUBY_RELEASE_MONTH 3