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:
parent
691b05e83c
commit
6e2ceaf0ed
2 changed files with 7 additions and 1 deletions
2
parse.y
2
parse.y
|
@ -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--;
|
||||
|
|
|
@ -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")}}
|
||||
|
|
Loading…
Reference in a new issue