ruby-changes:61950
From: nagachika <ko1@a...>
Date: Sat, 27 Jun 2020 12:20:51 +0900 (JST)
Subject: [ruby-changes:61950] d8a32b1465 (ruby_2_7): merge revision(s) 263b941321c3de6afc8f9dafbc2625f866b7437e: [Backport #16981]
https://git.ruby-lang.org/ruby.git/commit/?id=d8a32b1465 From d8a32b146561a0ddd3e60da9863a082b7e7725db Mon Sep 17 00:00:00 2001 From: nagachika <nagachika@r...> Date: Sat, 27 Jun 2020 12:20:36 +0900 Subject: merge revision(s) 263b941321c3de6afc8f9dafbc2625f866b7437e: [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. diff --git a/parse.y b/parse.y index d34d3f9..dc9c375 100644 --- a/parse.y +++ b/parse.y @@ -9495,16 +9495,17 @@ yylex(YYSTYPE *lval, YYLTYPE *yylloc, struct parser_params *p) https://github.com/ruby/ruby/blob/trunk/parse.y#L9495 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 feb3db0..80d455d 100644 --- a/test/ripper/test_parser_events.rb +++ b/test/ripper/test_parser_events.rb @@ -1535,6 +1535,12 @@ class TestRipper::ParserEvents < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ripper/test_parser_events.rb#L1535 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} diff --git a/version.h b/version.h index 7c3d755..725fab3 100644 --- a/version.h +++ b/version.h @@ -2,11 +2,11 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L2 # 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" -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/