diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-10-05 16:44:43 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-10-05 16:44:43 +0900 |
commit | 1f544d671580dab465df56f42e142db4667f782e (patch) | |
tree | 2a89d6c51fe82f14846f82f1c1195b363a88d5ed | |
parent | 5a961c37682383d5d439a16b912be62cd2d0a7f0 (diff) | |
download | ruby-1f544d671580dab465df56f42e142db4667f782e.tar.gz |
Show the last line at unexpected end-of-input error
-rw-r--r-- | parse.y | 4 | ||||
-rw-r--r-- | test/ruby/test_parse.rb | 4 |
2 files changed, 5 insertions, 3 deletions
@@ -5995,9 +5995,7 @@ parser_yyerror(struct parser_params *p, const YYLTYPE *yylloc, const char *msg) 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__ 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 |