From 38aa1376664f217cbbf74db0f49c8eebe098156a Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 16 Feb 2018 08:28:48 +0000 Subject: merge revision(s) 61617,61618: [Backport #14273] compile.c: remove more unreachable chunk * compile.c (remove_unreachable_chunk): remove beyond labels to be removed. 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/branches/ruby_2_5@62426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_syntax.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/ruby') 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