[前][次][番号順一覧][スレッド一覧]

ruby-changes:56232

From: Nobuyoshi <ko1@a...>
Date: Thu, 27 Jun 2019 15:35:17 +0900 (JST)
Subject: [ruby-changes:56232] Nobuyoshi Nakada: 097554855c (trunk): Fix ripper fatal

https://git.ruby-lang.org/ruby.git/commit/?id=097554855c

From 097554855c1a9404f3220bcc5c1906cc62399b59 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 27 Jun 2019 15:16:15 +0900
Subject: Fix ripper fatal

* parse.y (parser_yylex): return END_OF_INPUT at unterminated here
  document instead of an error.  [Bug #15962]

diff --git a/parse.y b/parse.y
index b966a0a..30f2696 100644
--- a/parse.y
+++ b/parse.y
@@ -8828,7 +8828,7 @@ parser_yylex(struct parser_params *p) https://github.com/ruby/ruby/blob/trunk/parse.y#L8828
 	    !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 eb423b3..cc3e208 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 https://github.com/ruby/ruby/blob/trunk/test/ripper/test_parser_events.rb#L489
     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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]