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

ruby-changes:64723

From: Nobuyoshi <ko1@a...>
Date: Mon, 4 Jan 2021 12:16:42 +0900 (JST)
Subject: [ruby-changes:64723] 35c3a24c8c (master): Fixed error message when % at EOF

https://git.ruby-lang.org/ruby.git/commit/?id=35c3a24c8c

From 35c3a24c8cbcccff1108079360e2063fc354b4bd Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Mon, 4 Jan 2021 12:11:37 +0900
Subject: Fixed error message when % at EOF


diff --git a/parse.y b/parse.y
index bd1717d..ff00fa8 100644
--- a/parse.y
+++ b/parse.y
@@ -8659,7 +8659,8 @@ parse_percent(struct parser_params *p, const int space_seen, const enum lex_stat https://github.com/ruby/ruby/blob/trunk/parse.y#L8659
 
 	c = nextc(p);
       quotation:
-	if (c == -1 || !ISALNUM(c)) {
+	if (c == -1) goto unterminated;
+	if (!ISALNUM(c)) {
 	    term = c;
 	    if (!ISASCII(c)) goto unknown;
 	    c = 'Q';
@@ -8677,6 +8678,7 @@ parse_percent(struct parser_params *p, const int space_seen, const enum lex_stat https://github.com/ruby/ruby/blob/trunk/parse.y#L8678
 	    }
 	}
 	if (term == -1) {
+	  unterminated:
 	    compile_error(p, "unterminated quoted string meets end of file");
 	    return 0;
 	}
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb
index 5f638af..4b7a12c 100644
--- a/test/ruby/test_parse.rb
+++ b/test/ruby/test_parse.rb
@@ -601,6 +601,7 @@ class TestParse < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L601
     assert_syntax_error('%z()', /unknown type/)
     assert_syntax_error("%\u3042", /unknown type/)
     assert_syntax_error("%q\u3042", /unknown type/)
+    assert_syntax_error("%", /unterminated quoted string/)
   end
 
   def test_symbol
-- 
cgit v0.10.2


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

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