1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Show the last line at unexpected end-of-input error

This commit is contained in:
Nobuyoshi Nakada 2021-10-05 16:44:43 +09:00
parent 5a961c3768
commit 1f544d6715
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
2 changed files with 5 additions and 3 deletions

View file

@ -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);

View file

@ -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