diff options
-rw-r--r-- | compile.c | 2 | ||||
-rw-r--r-- | test/ruby/test_optimization.rb | 6 |
2 files changed, 7 insertions, 1 deletions
@@ -2913,7 +2913,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal } else if (!iseq_pop_newarray(iseq, pobj)) { pobj = new_insn_core(iseq, pobj->insn_info.line_no, BIN(pop), 0, NULL); - ELEM_INSERT_NEXT(&iobj->link, &pobj->link); + ELEM_INSERT_PREV(&iobj->link, &pobj->link); } if (cond) { if (prev_dup) { 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 |