diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-14 04:35:28 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-14 04:35:28 +0000 |
commit | da09b6caef9c821929e4a0443629399418e27c1f (patch) | |
tree | a871a27820120384875b96c3e0819e743ca03b1a | |
parent | 5ed45420727985dce6e14c7bca529b4ead52a9d8 (diff) | |
download | ruby-da09b6caef9c821929e4a0443629399418e27c1f.tar.gz |
parse.y: fix yyerror message
* parse.y (parser_yyerror): show the error line even if the error
is at the end.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | parse.y | 5 | ||||
-rw-r--r-- | test/ruby/test_parse.rb | 5 |
2 files changed, 7 insertions, 3 deletions
@@ -5260,11 +5260,10 @@ parser_yyerror(struct parser_params *parser, const char *msg) int i; p = lex_p; - while (lex_pbeg <= p) { - if (*p == '\n') break; + while (lex_pbeg < p) { + if (*(p-1) == '\n') break; p--; } - p++; pe = lex_p; while (pe < lex_pend) { diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 57d03166c7..b4a63e369d 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -953,6 +953,11 @@ x = __ENCODING__ end end + def test_yyerror_at_eol + assert_syntax_error(" 0b", /\^/) + assert_syntax_error(" 0b\n", /\^/) + end + =begin def test_past_scope_variable assert_warning(/past scope/) {catch {|tag| eval("BEGIN{throw tag}; tap {a = 1}; a")}} |