diff --git a/parse.y b/parse.y index c09c9f9750..3a95252c58 100644 --- a/parse.y +++ b/parse.y @@ -9662,16 +9662,17 @@ yylex(YYSTYPE *lval, YYLTYPE *yylloc, struct parser_params *p) p->lval = lval; lval->val = Qundef; t = parser_yylex(p); - if (has_delayed_token(p)) - dispatch_delayed_token(p, t); - else if (t != 0) - dispatch_scan_event(p, t); if (p->lex.strterm && (p->lex.strterm->flags & STRTERM_HEREDOC)) RUBY_SET_YYLLOC_FROM_STRTERM_HEREDOC(*yylloc); else RUBY_SET_YYLLOC(*yylloc); + if (has_delayed_token(p)) + dispatch_delayed_token(p, t); + else if (t != 0) + dispatch_scan_event(p, t); + return t; } diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb index 87bd0d4e0b..b7118fcbb2 100644 --- a/test/ripper/test_parser_events.rb +++ b/test/ripper/test_parser_events.rb @@ -1538,6 +1538,12 @@ class TestRipper::ParserEvents < Test::Unit::TestCase assert_match(/encountered/, fmt) end + def test_warn_mismatched_indentations + fmt, tokend, tokbeg, line = assert_warning("") {break warn("if true\n end\n")} + assert_match(/mismatched indentations/, fmt) + assert_equal(["if", "end", 1], [tokbeg, tokend, line]) + end + def test_in thru_in = false parse('case 0; in 0; end', :on_in) {thru_in = true}