summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-26 23:32:12 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-26 23:32:12 +0000
commitf52f03394d9f439a6ecceca9d63804082a0f3a42 (patch)
tree7fbf70bc67fb7574a501684cc0957c5da2112075
parenteeb409a257629698b101c49813e08c008136d494 (diff)
merge revision(s) 34633: [Backport #5124]
* insns.def (splatarray): make new array if flag is set. * compile.c (iseq_compile_each): make new array with splat. [ruby-core:21901][Feature #1125] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@36228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--compile.c2
-rw-r--r--insns.def3
-rw-r--r--test/ruby/test_basicinstructions.rb7
-rw-r--r--version.h2
5 files changed, 18 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index c7be8fad27..1ab5a3f3cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Jun 27 08:31:50 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * insns.def (splatarray): make new array if flag is set.
+
+ * compile.c (iseq_compile_each): make new array with
+ splat. [ruby-core:21901][Feature #1125]
+
Wed Jun 27 04:23:26 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* win32/win32.c (rb_w32_sysinit): let the system not display the
diff --git a/compile.c b/compile.c
index 71059de085..f4211ed860 100644
--- a/compile.c
+++ b/compile.c
@@ -4629,7 +4629,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 a/insns.def b/insns.def
index 8f25fdcd07..49faec5d09 100644
--- a/insns.def
+++ b/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 a/test/ruby/test_basicinstructions.rb b/test/ruby/test_basicinstructions.rb
index ff14e4a7a6..7e57530d72 100644
--- a/test/ruby/test_basicinstructions.rb
+++ b/test/ruby/test_basicinstructions.rb
@@ -632,7 +632,7 @@ class TestBasicInstructions < Test::Unit::TestCase
assert_equal 'i', $~[9]
assert_equal 'x', $`
assert_equal 'abcdefghi', $&
- assert_equal 'y', $'
+ assert_equal "y", $'
assert_equal 'i', $+
assert_equal 'a', $1
assert_equal 'b', $2
@@ -662,15 +662,20 @@ class TestBasicInstructions < Test::Unit::TestCase
end
def test_array_splat
+ feature1125 = '[ruby-core:21901]'
+
a = []
assert_equal [], [*a]
assert_equal [1], [1, *a]
+ assert_not_same(a, [*a], feature1125)
a = [2]
assert_equal [2], [*a]
assert_equal [1, 2], [1, *a]
+ assert_not_same(a, [*a], feature1125)
a = [2, 3]
assert_equal [2, 3], [*a]
assert_equal [1, 2, 3], [1, *a]
+ assert_not_same(a, [*a], feature1125)
a = nil
assert_equal [], [*a]
diff --git a/version.h b/version.h
index e436236204..c3ee2beccc 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 241
+#define RUBY_PATCHLEVEL 242
#define RUBY_RELEASE_DATE "2012-06-27"
#define RUBY_RELEASE_YEAR 2012