From 1432471a759dc0cbc80c53766894dba45e6da887 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 29 Apr 2019 13:45:32 +0900 Subject: Disallow also CR in here-doc identifier * parse.y (heredoc_identifier): CR in here-document identifier might or might not result in a syntax error, by the EOL code. make a syntax error regardless of the EOL code. --- test/ruby/test_syntax.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/ruby/test_syntax.rb') diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 66adeb1c09..771764720b 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -857,6 +857,12 @@ eom assert_syntax_error("<<\"EOS\n\"\nEOS\n", /unterminated/) end + def test_unterminated_heredoc_cr + %W[\r\n \n].each do |nl| + assert_syntax_error("<<\"\r\"#{nl}\r#{nl}", /unterminated/, nil, "CR with #{nl.inspect}") + end + end + def test__END___cr assert_syntax_error("__END__\r<<<<<\n", /unexpected <