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

ruby-changes:47305

From: nobu <ko1@a...>
Date: Wed, 26 Jul 2017 09:56:51 +0900 (JST)
Subject: [ruby-changes:47305] nobu:r59420 (trunk): parse.y: brace after array literal arg

nobu	2017-07-26 09:56:44 +0900 (Wed, 26 Jul 2017)

  New Revision: 59420

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

  Log:
    parse.y: brace after array literal arg
    
    * parse.y (parser_yylex): array is another literal.  set state to
      END too not only ENDARG and after a literal, so that a left
      brace after it should be a primary block bound to the literal,
      which causes syntax error.  [ruby-core:81037] [Bug #13547]

  Modified files:
    trunk/parse.y
    trunk/test/ruby/test_syntax.rb
Index: test/ruby/test_syntax.rb
===================================================================
--- test/ruby/test_syntax.rb	(revision 59419)
+++ test/ruby/test_syntax.rb	(revision 59420)
@@ -974,6 +974,10 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L974
     assert_syntax_error('m 1.0 {}', error, bug)
     assert_syntax_error('m :m {}', error, bug)
     assert_syntax_error('m :"#{m}" {}', error, bug)
+    assert_syntax_error('m ?x {}', error, bug)
+    assert_syntax_error('m %[] {}', error, bug)
+    assert_syntax_error('m 0..1 {}', error, bug)
+    assert_syntax_error('m [] {}', error, bug)
   end
 
   def test_return_toplevel
Index: parse.y
===================================================================
--- parse.y	(revision 59419)
+++ parse.y	(revision 59420)
@@ -8374,7 +8374,7 @@ parser_yylex(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L8374
 	if (c == ')')
 	    SET_LEX_STATE(EXPR_ENDFN);
 	else
-	    SET_LEX_STATE(EXPR_ENDARG);
+	    SET_LEX_STATE(EXPR_END);
 	if (c == '}') {
 	    if (!brace_nest--) c = tSTRING_DEND;
 	}

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

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