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

ruby-changes:39543

From: nobu <ko1@a...>
Date: Tue, 18 Aug 2015 17:19:35 +0900 (JST)
Subject: [ruby-changes:39543] nobu:r51624 (trunk): parse.y: fix labelarg

nobu	2015-08-18 17:19:24 +0900 (Tue, 18 Aug 2015)

  New Revision: 51624

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

  Log:
    parse.y: fix labelarg
    
    * parse.y (IS_BEG): include labeled argument state, which was
      EXPR_LABELARG.  [ruby-dev:49221] [Bug #11456]

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
    trunk/test/ruby/test_syntax.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51623)
+++ ChangeLog	(revision 51624)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Aug 18 17:19:21 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (IS_BEG): include labeled argument state, which was
+	  EXPR_LABELARG.  [ruby-dev:49221] [Bug #11456]
+
 Tue Aug 18 16:16:21 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* include/ruby/ruby.h (RClass): define only in C, `__attribute__`
Index: parse.y
===================================================================
--- parse.y	(revision 51623)
+++ parse.y	(revision 51624)
@@ -7108,7 +7108,7 @@ parser_prepare(struct parser_params *par https://github.com/ruby/ruby/blob/trunk/parse.y#L7108
 
 #define IS_ARG() IS_lex_state(EXPR_ARG_ANY)
 #define IS_END() IS_lex_state(EXPR_END_ANY)
-#define IS_BEG() IS_lex_state(EXPR_BEG_ANY)
+#define IS_BEG() (IS_lex_state(EXPR_BEG_ANY) || IS_lex_state_all(EXPR_ARG|EXPR_LABELED))
 #define IS_SPCARG(c) (IS_ARG() && space_seen && !ISSPACE(c))
 #define IS_LABEL_POSSIBLE() (\
 	(IS_lex_state(EXPR_LABEL|EXPR_ENDFN) && !cmd_state) || \
@@ -8361,7 +8361,7 @@ parser_yylex(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L8361
 	return tSYMBEG;
 
       case '/':
-	if (IS_lex_state(EXPR_BEG_ANY)) {
+	if (IS_BEG()) {
 	    lex_strterm = NEW_STRTERM(str_regexp, '/', 0);
 	    return tREGEXP_BEG;
 	}
Index: test/ruby/test_syntax.rb
===================================================================
--- test/ruby/test_syntax.rb	(revision 51623)
+++ test/ruby/test_syntax.rb	(revision 51624)
@@ -310,6 +310,12 @@ WARN https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L310
     assert_valid_syntax("false ? raise do end : tap do end", bug10653)
   end
 
+  def test_paren_after_label
+    bug11456 = '[ruby-dev:49221] [Bug #11456]'
+    assert_valid_syntax("{foo: (1 rescue 0)}", bug11456)
+    assert_valid_syntax("{foo: /=/}", bug11456)
+  end
+
   def test_duplicated_arg
     assert_syntax_error("def foo(a, a) end", /duplicated argument name/)
     assert_nothing_raised { def foo(_, _) end }

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

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