1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Fix ripper fatal

* parse.y (parser_yylex): return END_OF_INPUT at unterminated here
  document instead of an error.  [Bug #15962]
This commit is contained in:
Nobuyoshi Nakada 2019-06-27 15:16:15 +09:00
parent 2a56702eee
commit 097554855c
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
2 changed files with 4 additions and 1 deletions

View file

@ -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);

View file

@ -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