summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 3e1034839e..76ca890b11 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Jan 17 03:51:48 2017 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]
+
Thu Nov 24 05:47:18 2016 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org>
* test/fileutils/test_fileutils.rb (TestFileUtils#setup): Use primary
diff --git a/compile.c b/compile.c
index f767dc4b05..9914ed3a8a 100644
--- a/compile.c
+++ b/compile.c
@@ -3615,7 +3615,7 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, unsigned int *flag, s
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;
@@ -3629,7 +3629,7 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, unsigned int *flag, s
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 fb79eadb64..4496d78210 100644
--- a/test/ruby/test_call.rb
+++ b/test/ruby/test_call.rb
@@ -90,4 +90,12 @@ class TestCall < Test::Unit::TestCase
h[:foo] = nil
}
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 c99d4abebb..fe5ea17d0c 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.3.3"
#define RUBY_RELEASE_DATE "2017-01-17"
-#define RUBY_PATCHLEVEL 226
+#define RUBY_PATCHLEVEL 227
#define RUBY_RELEASE_YEAR 2017
#define RUBY_RELEASE_MONTH 1