mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
compile.c: toplevel return in argument
* compile.c (iseq_compile_each0): adjust the stack before return in an evstr/argument (reported by Balazs <balazs@kutilovi.cz>) to fix stack consistency error. [ruby-core:81761] [Bug #13678] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d389625a1e
commit
8f1c93f409
2 changed files with 4 additions and 1 deletions
|
@ -5590,6 +5590,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int popp
|
|||
if (type == ISEQ_TYPE_TOP || type == ISEQ_TYPE_MAIN ||
|
||||
((type == ISEQ_TYPE_RESCUE || type == ISEQ_TYPE_ENSURE) &&
|
||||
(parent_type == ISEQ_TYPE_TOP || parent_type == ISEQ_TYPE_MAIN))) {
|
||||
ADD_ADJUST(ret, line, 0);
|
||||
ADD_INSN(ret, line, putnil);
|
||||
ADD_INSN(ret, line, leave);
|
||||
}
|
||||
|
|
|
@ -964,7 +964,7 @@ eom
|
|||
|
||||
def test_return_toplevel
|
||||
feature4840 = '[ruby-core:36785] [Feature #4840]'
|
||||
code = "#{<<~"begin;"}\n#{<<~"end;"}"
|
||||
code = "#{<<~"begin;"}\n#{<<~'end;'}"
|
||||
begin;
|
||||
return; raise
|
||||
begin return; rescue SystemExit; exit false; end
|
||||
|
@ -974,6 +974,8 @@ eom
|
|||
begin raise; rescue; return; end
|
||||
return false; raise
|
||||
return 1; raise
|
||||
"#{return}"
|
||||
raise((return; "should not raise"))
|
||||
end;
|
||||
all_assertions(feature4840) do |a|
|
||||
code.each_line do |s|
|
||||
|
|
Loading…
Reference in a new issue