From 1344de56219cf83ca146c5346783f8483af534f9 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 22 Jun 2023 20:10:13 +0900 Subject: [PATCH] [Bug #19743] All but EOF can be read again after push-back --- parse.y | 2 ++ test/ruby/test_parse.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/parse.y b/parse.y index 76386e47edc8cf..329b578f367d21 100644 --- a/parse.y +++ b/parse.y @@ -7121,6 +7121,7 @@ static void pushback(struct parser_params *p, int c) { if (c == -1) return; + p->eofp = 0; p->lex.pcur--; if (p->lex.pcur > p->lex.pbeg && p->lex.pcur[0] == '\n' && p->lex.pcur[-1] == '\r') { p->lex.pcur--; @@ -9164,6 +9165,7 @@ parse_numeric(struct parser_params *p, int c) c = nextc(p); if (c != '-' && c != '+' && !ISDIGIT(c)) { pushback(p, c); + c = nondigit; nondigit = 0; goto decode_num; } diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 099050dc8d4bee..bf0d9f1bd5c46e 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -1138,6 +1138,8 @@ def test_unexpected_token_after_numeric assert_syntax_error('0000xyz', /^ \^~~\Z/) assert_syntax_error('1.2i1.1', /^ \^~~\Z/) assert_syntax_error('1.2.3', /^ \^~\Z/) + assert_syntax_error('1.', /unexpected end-of-input/) + assert_syntax_error('1e', /expecting end-of-input/) end def test_truncated_source_line