From 6be402e172a537000de58a28af389cb55dd62ec8 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 20 Jun 2023 20:10:46 +0900 Subject: [PATCH] [Bug #19736] Recover after unterminated interpolation --- parse.y | 6 +++++- test/ripper/test_lexer.rb | 9 +++++++++ test/ruby/test_parse.rb | 9 +++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/parse.y b/parse.y index 616b2fe4f4..76386e47ed 100644 --- a/parse.y +++ b/parse.y @@ -5331,7 +5331,7 @@ string_content : tSTRING_CONTENT $$ = p->heredoc_indent; p->heredoc_indent = 0; } - compstmt tSTRING_DEND + compstmt string_dend { COND_POP(); CMDARG_POP(); @@ -5348,6 +5348,10 @@ string_content : tSTRING_CONTENT } ; +string_dend : tSTRING_DEND + | END_OF_INPUT + ; + string_dvar : tGVAR { /*%%%*/ diff --git a/test/ripper/test_lexer.rb b/test/ripper/test_lexer.rb index 8e8a616627..92587ae4c0 100644 --- a/test/ripper/test_lexer.rb +++ b/test/ripper/test_lexer.rb @@ -264,4 +264,13 @@ world" CODE assert_equal(code, Ripper.tokenize(code).join(""), bug) end + + def test_heredoc_unterminated_interpolation + code = <<~'HEREDOC' + <