[前][次][番号順一覧][スレッド一覧]

ruby-changes:45137

From: usa <ko1@a...>
Date: Tue, 27 Dec 2016 18:34:46 +0900 (JST)
Subject: [ruby-changes:45137] usa:r57210 (ruby_2_2): merge revision(s) 56469: [Backport #12860]

usa	2016-12-27 18:34:40 +0900 (Tue, 27 Dec 2016)

  New Revision: 57210

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57210

  Log:
    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]

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/compile.c
    branches/ruby_2_2/test/ruby/test_call.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 57209)
+++ ruby_2_2/ChangeLog	(revision 57210)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Tue Dec 27 18:34:04 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@r...>
 
 	* dln.c (dln_load): raise LoadError instead of fatal error on
Index: ruby_2_2/compile.c
===================================================================
--- ruby_2_2/compile.c	(revision 57209)
+++ ruby_2_2/compile.c	(revision 57210)
@@ -3267,7 +3267,7 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR https://github.com/ruby/ruby/blob/trunk/ruby_2_2/compile.c#L3267
 	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 https://github.com/ruby/ruby/blob/trunk/ruby_2_2/compile.c#L3281
 	    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));
Index: ruby_2_2/test/ruby/test_call.rb
===================================================================
--- ruby_2_2/test/ruby/test_call.rb	(revision 57209)
+++ ruby_2_2/test/ruby/test_call.rb	(revision 57210)
@@ -31,4 +31,12 @@ class TestCall < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_call.rb#L31
     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
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 57209)
+++ ruby_2_2/version.h	(revision 57210)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #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

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r56469


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]