From 43c1eb440a7adedfb3cc1063b63573ade714c76a Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 5 Jan 2018 14:23:23 +0000 Subject: compile.c: fix stack consistency error * compile.c (iseq_peephole_optimize): fix stack consistency error from return in loop, by adding extra `pop` when replacing `jump` with `leave`, which is never reached but needed to adjust sp calculation. [ruby-core:84589] [Bug #14273] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_syntax.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test') diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index aa82f52987..8bf1627f3b 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -1128,6 +1128,15 @@ eom assert_equal(:begin, result) end + def test_return_in_loop + obj = Object.new + def obj.test + x = nil + return until x unless x + end + assert_nil obj.test + end + private def not_label(x) @result = x; @not_label ||= nil end -- cgit v1.2.3