summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-24 10:38:39 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-24 10:38:39 +0000
commit71b0d20f7ea6b04aa3ae3fe6e624305a3ac294e6 (patch)
tree8a1ed2bfd160bc288b899ea9de1f142b358b80bd /test
parentcd0181dd68788b2159d9c740168f16e1f510fbe4 (diff)
compile.c: fix peephole optimization
* compile.c (iseq_peephole_optimize): should `pop` before jump instruction which succeeds to `newarray` of a literal object, not after. [ruby-core:89536] [Bug #15245] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_optimization.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb
index c425254661..46bce922b9 100644
--- a/test/ruby/test_optimization.rb
+++ b/test/ruby/test_optimization.rb
@@ -794,4 +794,10 @@ class TestRubyOptimization < Test::Unit::TestCase
end
assert_equal(:ok, x.bug(:ok))
end
+
+ def test_peephole_jump_after_newarray
+ i = 0
+ %w(1) || 2 while (i += 1) < 100
+ assert_equal(100, i)
+ end
end