Hi,

(12/02/13 23:27), Yusuke Endoh wrote:
> I'll commit the following patch unless there is objection:

Isn't the flag of splatarray for this purpose?


diff --git i/compile.c w/compile.c index 32bda52..c8aced3 100644 --- i/compile.c +++ w/compile.c @@ -4643,7 +4643,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) } case NODE_SPLAT:{ COMPILE(ret, "splat", node->nd_head); - ADD_INSN1(ret, nd_line(node), splatarray, Qfalse); + ADD_INSN1(ret, nd_line(node), splatarray, Qtrue); if (poped) { ADD_INSN(ret, nd_line(node), pop); diff --git i/insns.def w/insns.def index 8ec05de..59a98c0 100644 --- i/insns.def +++ w/insns.def @@ -533,6 +533,9 @@ splatarray if (NIL_P(tmp)) { tmp = rb_ary_new3(1, ary); } + else if (RTEST(flag)) { + tmp = rb_ary_dup(tmp); + } obj = tmp; } diff --git i/test/ruby/test_basicinstructions.rb w/test/ruby/test_basicinstructions.rb index ff14e4a..fdcd1b0 100644 --- i/test/ruby/test_basicinstructions.rb +++ w/test/ruby/test_basicinstructions.rb @@ -665,12 +665,15 @@ class TestBasicInstructions < Test::Unit::TestCase a = [] assert_equal [], [*a] assert_equal [1], [1, *a] + assert_not_same a, [*a] a = [2] assert_equal [2], [*a] assert_equal [1, 2], [1, *a] + assert_not_same a, [*a] a = [2, 3] assert_equal [2, 3], [*a] assert_equal [1, 2, 3], [1, *a] + assert_not_same a, [*a] a = nil assert_equal [], [*a]
-- Nobu Nakada