mirror of
https://github.com/ruby/ruby.git
synced 2025-09-16 17:14:01 +02:00
merge revision(s) 263b941321
: [Backport #16981]
[ripper] fix mismatched indentations warning [Bug #16981] The scanner location has to be set from `lex.ptok` before it is flushed by dispatching the scanner event.
This commit is contained in:
parent
3c55d93cf6
commit
d8a32b1465
3 changed files with 13 additions and 6 deletions
9
parse.y
9
parse.y
|
@ -9495,16 +9495,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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1535,6 +1535,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}
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
||||
#define RUBY_VERSION_TEENY 1
|
||||
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
||||
#define RUBY_PATCHLEVEL 85
|
||||
#define RUBY_PATCHLEVEL 86
|
||||
|
||||
#define RUBY_RELEASE_YEAR 2020
|
||||
#define RUBY_RELEASE_MONTH 6
|
||||
#define RUBY_RELEASE_DAY 13
|
||||
#define RUBY_RELEASE_DAY 27
|
||||
|
||||
#include "ruby/version.h"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue