summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--parse.y2
-rw-r--r--test/ripper/test_parser_events.rb3
2 files changed, 4 insertions, 1 deletions
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("<<a"))
assert_match("can't find string \"a\" anywhere before EOF", compile_error('<<"a"'))
assert_match("can't find string \"a\" anywhere before EOF", compile_error("<<'a'"))
+ msg = nil
+ parse('<<"', :on_parse_error) {|_, e| msg = e}
+ assert_equal("unterminated here document identifier", msg)
end
def test_massign