ruby-changes:45001
From: nobu <ko1@a...>
Date: Wed, 14 Dec 2016 13:35:35 +0900 (JST)
Subject: [ruby-changes:45001] nobu:r57073 (trunk): parse.y: fix yyerror message
nobu 2016-12-14 13:35:28 +0900 (Wed, 14 Dec 2016) New Revision: 57073 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57073 Log: parse.y: fix yyerror message * parse.y (parser_yyerror): show the error line even if the error is at the end. Modified files: trunk/parse.y trunk/test/ruby/test_parse.rb Index: test/ruby/test_parse.rb =================================================================== --- test/ruby/test_parse.rb (revision 57072) +++ test/ruby/test_parse.rb (revision 57073) @@ -953,6 +953,11 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L953 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")}} Index: parse.y =================================================================== --- parse.y (revision 57072) +++ parse.y (revision 57073) @@ -5260,11 +5260,10 @@ parser_yyerror(struct parser_params *par https://github.com/ruby/ruby/blob/trunk/parse.y#L5260 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) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/