diff options
| -rw-r--r-- | parse.y | 6 | ||||
| -rw-r--r-- | test/ruby/test_beginendblock.rb | 3 |
2 files changed, 5 insertions, 4 deletions
@@ -3296,6 +3296,9 @@ allow_exits : {$$ = allow_block_exit(p);}; k_END : keyword_END lex_ctxt { + if (p->ctxt.in_def) { + rb_warn0("END in method; use at_exit"); + } $$ = $2; p->ctxt.in_rescue = before_rescue; /*% ripper: $:2 %*/ @@ -3380,9 +3383,6 @@ stmt : keyword_alias[kw] fitem[new] {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fit } | k_END[k_end] allow_exits[allow] '{'[lbrace] compstmt(stmts)[body] '}'[rbrace] { - if (p->ctxt.in_def) { - rb_warn0("END in method; use at_exit"); - } restore_block_exit(p, $allow); p->ctxt = $k_end; { diff --git a/test/ruby/test_beginendblock.rb b/test/ruby/test_beginendblock.rb index 3706efab52..74da11abf4 100644 --- a/test/ruby/test_beginendblock.rb +++ b/test/ruby/test_beginendblock.rb @@ -40,7 +40,8 @@ class TestBeginEndBlock < Test::Unit::TestCase assert_in_out_err([], "#{<<~"begin;"}#{<<~'end;'}", [], ['-:2: warning: END in method; use at_exit']) begin; def end1 - END {} + END { + } end end; end |
