ruby-changes:68266
From: Nobuyoshi <ko1@a...>
Date: Tue, 5 Oct 2021 16:49:52 +0900 (JST)
Subject: [ruby-changes:68266] 1f544d6715 (master): Show the last line at unexpected end-of-input error
https://git.ruby-lang.org/ruby.git/commit/?id=1f544d6715 From 1f544d671580dab465df56f42e142db4667f782e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 5 Oct 2021 16:44:43 +0900 Subject: Show the last line at unexpected end-of-input error --- parse.y | 4 +--- test/ruby/test_parse.rb | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/parse.y b/parse.y index 3d5ba3b1ea..1f000a13de 100644 --- a/parse.y +++ b/parse.y @@ -5995,9 +5995,7 @@ parser_yyerror(struct parser_params *p, const YYLTYPE *yylloc, const char *msg) https://github.com/ruby/ruby/blob/trunk/parse.y#L5995 yylloc = RUBY_SET_YYLLOC(current); } else if ((p->ruby_sourceline != yylloc->beg_pos.lineno && - p->ruby_sourceline != yylloc->end_pos.lineno) || - (yylloc->beg_pos.lineno == yylloc->end_pos.lineno && - yylloc->beg_pos.column == yylloc->end_pos.column)) { + p->ruby_sourceline != yylloc->end_pos.lineno)) { yylloc = 0; } compile_error(p, "%s", msg); diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 625b6eb223..a9e8417357 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -1162,6 +1162,10 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L1162 assert_syntax_error("def m\n\C-z""end", /unexpected/) end + def test_unexpected_eof + assert_syntax_error('unless', /^ \^\Z/) + end + def test_location_of_invalid_token assert_syntax_error('class xxx end', /^ \^~~\Z/) end -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/