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

ruby-changes:54507

From: nobu <ko1@a...>
Date: Sat, 5 Jan 2019 20:35:29 +0900 (JST)
Subject: [ruby-changes:54507] nobu:r66722 (trunk): parse.y: refine error messages

nobu	2019-01-05 20:35:24 +0900 (Sat, 05 Jan 2019)

  New Revision: 66722

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66722

  Log:
    parse.y: refine error messages
    
    * parse.y: refine error messages for tSYMBEG and tSTRING_BEG, which
      can appear at invalid places.

  Modified files:
    trunk/parse.y
    trunk/test/ruby/test_syntax.rb
Index: test/ruby/test_syntax.rb
===================================================================
--- test/ruby/test_syntax.rb	(revision 66721)
+++ test/ruby/test_syntax.rb	(revision 66722)
@@ -905,6 +905,11 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L905
     assert_syntax_error(":#\n foo", /unexpected ':'/)
   end
 
+  def test_invalid_literal_message
+    assert_syntax_error("def :foo", /unexpected symbol literal/)
+    assert_syntax_error("def 'foo'", /unexpected string literal/)
+  end
+
   def test_fluent_dot
     assert_valid_syntax("a\n.foo")
     assert_valid_syntax("a\n&.foo")
Index: parse.y
===================================================================
--- parse.y	(revision 66721)
+++ parse.y	(revision 66722)
@@ -900,7 +900,9 @@ static void token_info_warn(struct parse https://github.com/ruby/ruby/blob/trunk/parse.y#L900
 %token tDSTAR		"**arg"
 %token tAMPER		"&"
 %token tLAMBDA		"->"
-%token tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG tWORDS_BEG tQWORDS_BEG tSYMBOLS_BEG tQSYMBOLS_BEG
+%token tSYMBEG		"symbol literal"
+%token tSTRING_BEG	"string literal"
+%token tXSTRING_BEG tREGEXP_BEG tWORDS_BEG tQWORDS_BEG tSYMBOLS_BEG tQSYMBOLS_BEG
 %token tSTRING_DBEG tSTRING_DEND tSTRING_DVAR tSTRING_END tLAMBEG tLABEL_END
 
 /*

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

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