summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eval_error.c7
-rw-r--r--test/ruby/test_syntax.rb5
2 files changed, 11 insertions, 1 deletions
diff --git a/eval_error.c b/eval_error.c
index 04891f4369..bdce295f6e 100644
--- a/eval_error.c
+++ b/eval_error.c
@@ -461,7 +461,12 @@ exiting_split(VALUE errinfo, volatile int *exitcode, volatile int *sigstatus)
if (NIL_P(errinfo)) return 0;
- if (rb_obj_is_kind_of(errinfo, rb_eSystemExit)) {
+ if (THROW_DATA_P(errinfo)) {
+ int throw_state = ((const struct vm_throw_data *)errinfo)->throw_state;
+ ex = throw_state & VM_THROW_STATE_MASK;
+ result |= EXITING_WITH_STATUS;
+ }
+ else if (rb_obj_is_kind_of(errinfo, rb_eSystemExit)) {
ex = sysexit_status(errinfo);
result |= EXITING_WITH_STATUS;
}
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 5c382fac7a..670bb27892 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -1370,6 +1370,7 @@ eom
nil&defined?0--begin e=no_method_error(); return; 0;end
return puts('ignored') #=> ignored
BEGIN {return}
+ END {return if false}
end;
.split(/\n/).map {|s|[(line+=1), *s.split(/#=> /, 2)]}
failed = proc do |n, s|
@@ -1407,6 +1408,10 @@ eom
assert_in_out_err(['-e', 'class TestSyntax; proc{ return }.call; end'], "", [], /^-e:1:.*unexpected return \(LocalJumpError\)/)
end
+ def test_return_in_END
+ assert_normal_exit('END {return}')
+ end
+
def test_syntax_error_in_rescue
bug12613 = '[ruby-core:76531] [Bug #12613]'
assert_syntax_error("#{<<-"begin;"}\n#{<<-"end;"}", /Invalid retry/, bug12613)