From 330b376133e00ae418bcf01e641e127df01fbc28 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 29 Apr 2019 00:24:26 +0900 Subject: parse.y: fix here-doc identifier with newline * parse.y (heredoc_identifier): quoted here-document identifier must end within the same line. the only corner case that here-document identifier can contain a newline is that the closing qoute is placed at the beginning of the next line, and has been warned since 2.4. ```ruby <<"EOS " # warning: here document identifier ends with a newline EOS ``` --- test/ruby/test_syntax.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'test/ruby') diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 257fe07b3c..66adeb1c09 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -852,10 +852,9 @@ eom assert_syntax_error("puts <<""EOS\n""ng\n""EOS\r""NO\n", /can't find string "EOS" anywhere before EOF/) end - def test_heredoc_newline - assert_warn(/ends with a newline/) do - eval("<<\"EOS\n\"\nEOS\n") - end + def test_unterminated_heredoc + assert_syntax_error("<<\"EOS\n\nEOS\n", /unterminated/) + assert_syntax_error("<<\"EOS\n\"\nEOS\n", /unterminated/) end def test__END___cr -- cgit v1.2.3