From 097554855c1a9404f3220bcc5c1906cc62399b59 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 27 Jun 2019 15:16:15 +0900 Subject: [PATCH] Fix ripper fatal * parse.y (parser_yylex): return END_OF_INPUT at unterminated here document instead of an error. [Bug #15962] --- parse.y | 2 +- test/ripper/test_parser_events.rb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/parse.y b/parse.y index b966a0abc9..30f2696c23 100644 --- a/parse.y +++ b/parse.y @@ -8828,7 +8828,7 @@ parser_yylex(struct parser_params *p) !IS_END() && (!IS_ARG() || IS_lex_state(EXPR_LABELED) || space_seen)) { int token = heredoc_identifier(p); - if (token) return token; + if (token) return token < 0 ? 0 : token; } if (IS_AFTER_OPERATOR()) { SET_LEX_STATE(EXPR_ARG); diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb index eb423b397e..cc3e208d41 100644 --- a/test/ripper/test_parser_events.rb +++ b/test/ripper/test_parser_events.rb @@ -489,6 +489,9 @@ class TestRipper::ParserEvents < Test::Unit::TestCase assert_match("can't find string \"a\" anywhere before EOF", compile_error("<