From 976b6df9596a2077f09f6bed1796a02a229498d1 Mon Sep 17 00:00:00 2001 From: ko1 Date: Thu, 9 Nov 2017 04:27:27 +0000 Subject: fix peephole optimization. * compile.c (iseq_peephole_optimize): do not need to put `pop` instruction. * test/ruby/test_optimization.rb (test_peephole_optimization_without_trace): This code "def foo; 1.times{|(a), &b| nil && a}; end" fails to compile by stack underflow because of above bug (fixed by this patch). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_optimization.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/ruby/test_optimization.rb') diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb index ed16ad9fe2..40015c57dd 100644 --- a/test/ruby/test_optimization.rb +++ b/test/ruby/test_optimization.rb @@ -640,4 +640,11 @@ class TestRubyOptimization < Test::Unit::TestCase assert_equal 0, foo{$SAFE} END end + + def test_peephole_optimization_without_trace + assert_separately [], <<-END + RubyVM::InstructionSequence.compile_option = {trace_instruction: false} + eval "def foo; 1.times{|(a), &b| nil && a}; end" + END + end end -- cgit v1.2.3