summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-27 09:34:40 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-27 09:34:40 +0000
commita078bbcc172dae52bfd8bf9d25f7736a544972e8 (patch)
treef1dcd13fe4e177fd967579347ff5c83d1987651a
parent16d03ff2a46dda3dab40caeb794b8a890b024e05 (diff)
merge revision(s) 56469: [Backport #12860]
* compile.c (setup_args): duplicate splatting array if more arguments present to obey left-to-right execution order. [ruby-core:77701] [Bug# 12860] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@57210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--compile.c4
-rw-r--r--test/ruby/test_call.rb8
-rw-r--r--version.h2
4 files changed, 17 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 312c825b76..eb2bd0b5d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Dec 27 18:34:04 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * compile.c (setup_args): duplicate splatting array if more
+ arguments present to obey left-to-right execution order.
+ [ruby-core:77701] [Bug# 12860]
+
Tue Dec 27 18:28:20 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* dln.c (dln_load): raise LoadError instead of fatal error on
diff --git a/compile.c b/compile.c
index 36db683c4a..e6742f073e 100644
--- a/compile.c
+++ b/compile.c
@@ -3267,7 +3267,7 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, unsigned int *flag, r
switch (nd_type(argn)) {
case NODE_SPLAT: {
COMPILE(args, "args (splat)", argn->nd_head);
- ADD_INSN1(args, nd_line(argn), splatarray, Qfalse);
+ ADD_INSN1(args, nd_line(argn), splatarray, nsplat ? Qtrue : Qfalse);
argc = INT2FIX(1);
nsplat++;
*flag |= VM_CALL_ARGS_SPLAT;
@@ -3281,7 +3281,7 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, unsigned int *flag, r
INIT_ANCHOR(tmp);
COMPILE(tmp, "args (cat: splat)", argn->nd_body);
if (nd_type(argn) == NODE_ARGSCAT) {
- ADD_INSN1(tmp, nd_line(argn), splatarray, Qfalse);
+ ADD_INSN1(tmp, nd_line(argn), splatarray, nsplat ? Qtrue : Qfalse);
}
else {
ADD_INSN1(tmp, nd_line(argn), newarray, INT2FIX(1));
diff --git a/test/ruby/test_call.rb b/test/ruby/test_call.rb
index 5b81eb187a..d5319e7c7c 100644
--- a/test/ruby/test_call.rb
+++ b/test/ruby/test_call.rb
@@ -31,4 +31,12 @@ class TestCall < Test::Unit::TestCase
assert_nothing_raised(ArgumentError) {o.foo}
assert_raise_with_message(ArgumentError, e.message, bug9622) {o.foo(100)}
end
+
+ def test_call_splat_order
+ bug12860 = '[ruby-core:77701] [Bug# 12860]'
+ ary = [1, 2]
+ assert_equal([1, 2, 1], aaa(*ary, ary.shift), bug12860)
+ ary = [1, 2]
+ assert_equal([0, 1, 2, 1], aaa(0, *ary, ary.shift), bug12860)
+ end
end
diff --git a/version.h b/version.h
index b3a9196023..f5a63c4fec 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.2.7"
#define RUBY_RELEASE_DATE "2016-12-27"
-#define RUBY_PATCHLEVEL 400
+#define RUBY_PATCHLEVEL 401
#define RUBY_RELEASE_YEAR 2016
#define RUBY_RELEASE_MONTH 12