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:
parent
5a961c3768
commit
1f544d6715
2 changed files with 5 additions and 3 deletions
4
parse.y
4
parse.y
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue