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

ruby-changes:42404

From: nagachika <ko1@a...>
Date: Sun, 3 Apr 2016 23:45:13 +0900 (JST)
Subject: [ruby-changes:42404] nagachika:r54478 (ruby_2_3): merge revision(s) 53495: [Backport #11970]

nagachika	2016-04-04 00:41:45 +0900 (Mon, 04 Apr 2016)

  New Revision: 54478

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

  Log:
    merge revision(s) 53495: [Backport #11970]
    
    * compile.c (compile_massign_lhs): when index ends with splat,
      append rhs value to it like POSTARG, since VM_CALL_ARGS_SPLAT
      splats the last argument only.  [ruby-core:72777] [Bug #11970]

  Modified directories:
    branches/ruby_2_3/
  Modified files:
    branches/ruby_2_3/ChangeLog
    branches/ruby_2_3/compile.c
    branches/ruby_2_3/test/ruby/test_assignment.rb
    branches/ruby_2_3/version.h
Index: ruby_2_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 54477)
+++ ruby_2_3/version.h	(revision 54478)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.0"
-#define RUBY_RELEASE_DATE "2016-04-02"
-#define RUBY_PATCHLEVEL 72
+#define RUBY_RELEASE_DATE "2016-04-04"
+#define RUBY_PATCHLEVEL 73
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 4
-#define RUBY_RELEASE_DAY 2
+#define RUBY_RELEASE_DAY 4
 
 #include "ruby/version.h"
 
Index: ruby_2_3/ChangeLog
===================================================================
--- ruby_2_3/ChangeLog	(revision 54477)
+++ ruby_2_3/ChangeLog	(revision 54478)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1
+Mon Apr  4 00:31:51 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* compile.c (compile_massign_lhs): when index ends with splat,
+	  append rhs value to it like POSTARG, since VM_CALL_ARGS_SPLAT
+	  splats the last argument only.  [ruby-core:72777] [Bug #11970]
+
 Sat Apr  2 02:07:29 2016  Seiei Miyagi  <hanachin@g...>
 
 	* ext/ripper/lib/ripper/lexer.rb (on_heredoc_dedent): Fix
Index: ruby_2_3/compile.c
===================================================================
--- ruby_2_3/compile.c	(revision 54477)
+++ ruby_2_3/compile.c	(revision 54478)
@@ -192,11 +192,20 @@ r_value(VALUE value) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/compile.c#L192
 #define ADD_INSN(seq, line, insn) \
   ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_body(iseq, (line), BIN(insn), 0))
 
+/* insert an instruction before prev */
+#define INSERT_BEFORE_INSN(prev, line, insn) \
+  INSERT_ELEM_PREV(&(prev)->link, (LINK_ELEMENT *) new_insn_body(iseq, (line), BIN(insn), 0))
+
 /* add an instruction with some operands (1, 2, 3, 5) */
 #define ADD_INSN1(seq, line, insn, op1) \
   ADD_ELEM((seq), (LINK_ELEMENT *) \
            new_insn_body(iseq, (line), BIN(insn), 1, (VALUE)(op1)))
 
+/* insert an instruction with some operands (1, 2, 3, 5) before prev */
+#define INSERT_BEFORE_INSN1(prev, line, insn, op1) \
+  INSERT_ELEM_PREV(&(prev)->link, (LINK_ELEMENT *) \
+           new_insn_body(iseq, (line), BIN(insn), 1, (VALUE)(op1)))
+
 #define LABEL_REF(label) ((label)->refcnt++)
 
 /* add an instruction with label operand (alias of ADD_INSN1) */
@@ -2983,9 +2992,10 @@ compile_massign_lhs(rb_iseq_t *iseq, LIN https://github.com/ruby/ruby/blob/trunk/ruby_2_3/compile.c#L2992
 {
     switch (nd_type(node)) {
       case NODE_ATTRASGN: {
-	INSN *iobj, *topdup;
+	INSN *iobj;
 	struct rb_call_info *ci;
 	VALUE dupidx;
+	int line = nd_line(node);
 
 	COMPILE_POPED(ret, "masgn lhs (NODE_ATTRASGN)", node);
 
@@ -2994,9 +3004,13 @@ compile_massign_lhs(rb_iseq_t *iseq, LIN https://github.com/ruby/ruby/blob/trunk/ruby_2_3/compile.c#L3004
 	ci->orig_argc += 1;
 	dupidx = INT2FIX(ci->orig_argc);
 
-	topdup = new_insn_body(iseq, nd_line(node), BIN(topn), 1, dupidx);
-	INSERT_ELEM_PREV(&iobj->link, &topdup->link);
-	ADD_INSN(ret, nd_line(node), pop);	/* result */
+	INSERT_BEFORE_INSN1(iobj, line, topn, dupidx);
+	if (ci->flag & VM_CALL_ARGS_SPLAT) {
+	    --ci->orig_argc;
+	    INSERT_BEFORE_INSN1(iobj, line, newarray, INT2FIX(1));
+	    INSERT_BEFORE_INSN(iobj, line, concatarray);
+	}
+	ADD_INSN(ret, line, pop);	/* result */
 	break;
       }
       case NODE_MASGN: {
Index: ruby_2_3/test/ruby/test_assignment.rb
===================================================================
--- ruby_2_3/test/ruby/test_assignment.rb	(revision 54477)
+++ ruby_2_3/test/ruby/test_assignment.rb	(revision 54478)
@@ -758,4 +758,12 @@ class TestAssignmentGen < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_assignment.rb#L758
     o = bug9448.new
     assert_equal("ok", o['current'] = "ok")
   end
+
+  def test_massign_aref_lhs_splat
+    bug11970 = '[ruby-core:72777] [Bug #11970]'
+    h = {}
+    k = [:key]
+    h[*k], = ["ok", "ng"]
+    assert_equal("ok", h[:key], bug11970)
+  end
 end

Property changes on: ruby_2_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r53495


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

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