fix return in toplevel rescue/ensure

* compile.c (iseq_compile_each0): throw TAG_RETURN at return in
  toplevel rescue/ensure to adjust VM stack properly.
  [ruby-core:81777] [Bug #13682]

* vm_insnhelper.c (vm_throw_start): allow return in toplevel
  rescue/ensure.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-06-27 06:57:34 +00:00
parent c95cbf6aab
commit 1474acff3c
4 changed files with 39 additions and 4 deletions

View file

@ -525,4 +525,14 @@ class TestEval < Test::Unit::TestCase
b.eval('yield')
}, '[Bug #10368]'
end
def test_return_in_eval_proc
x = proc {eval("return :ng")}
assert_raise(LocalJumpError) {x.call}
end
def test_return_in_eval_lambda
x = lambda {eval("return :ok")}
assert_equal(:ok, x.call)
end
end