Project

General

Profile

Feature #4840 » 0001-compile.c-toplevel-return.patch

nobu (Nobuyoshi Nakada), 05/09/2013 11:14 AM

View differences:

compile.c
rb_iseq_t *is = iseq;
if (is) {
if (is->type == ISEQ_TYPE_TOP) {
COMPILE_ERROR((ERROR_ARGS "Invalid return"));
if (is->type == ISEQ_TYPE_TOP || is->type == ISEQ_TYPE_MAIN) {
ADD_INSN(ret, line, putnil);
ADD_INSN(ret, line, leave);
}
else {
LABEL *splabel = 0;
test/ruby/test_syntax.rb
assert_constant_reassignment_toplevel("11", "+", %w[53], already)
end
def test_return_toplevel
feature4840 = '[ruby-core:36785] [Feature #4840]'
assert_ruby_status([], "return; raise", feature4840)
assert_ruby_status([], "begin return; resucue SystemExit; exit false; end", feature4840)
assert_ruby_status([], "begin return; ensure exit false; end", feature4840)
assert_ruby_status([], "return false; raise", feature4840)
assert_ruby_status([], "return 1; raise", feature4840)
end
private
def not_label(x) @result = x; @not_label ||= nil end
(2-2/2)