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

parse.y: code end position

* parse.y (parser_yyerror): use the given location as the end of
  erred code, instead of the current position.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-01-02 03:00:13 +00:00
parent 691b05e83c
commit 6e2ceaf0ed
2 changed files with 7 additions and 1 deletions

View file

@ -5378,7 +5378,7 @@ parser_yyerror(struct parser_params *parser, const YYLTYPE *yylloc, const char *
}
pt = (ruby_sourceline == yylloc->last_loc.lineno) ?
lex_p : lex_pend;
lex_pbeg + yylloc->last_loc.column : lex_pend;
p = pe = pt < pend ? pt : pend;
lim = p - lex_pbeg > max_line_margin ? p - max_line_margin : lex_pbeg;
while ((lim < p) && (*(p-1) != '\n')) p--;

View file

@ -1099,6 +1099,12 @@ x = __ENCODING__
assert_raise(SyntaxError) { eval("def m\n\C-z""end") }
end
def test_location_of_invalid_token
assert_raise_with_message(SyntaxError, /^ \^~~\z/) do
eval('class xxx end')
end
end
=begin
def test_past_scope_variable
assert_warning(/past scope/) {catch {|tag| eval("BEGIN{throw tag}; tap {a = 1}; a")}}