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

ruby-changes:44125

From: nobu <ko1@a...>
Date: Wed, 21 Sep 2016 13:38:51 +0900 (JST)
Subject: [ruby-changes:44125] nobu:r56198 (trunk): parse.y: do after cmdarg in paren

nobu	2016-09-21 13:38:46 +0900 (Wed, 21 Sep 2016)

  New Revision: 56198

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

  Log:
    parse.y: do after cmdarg in paren
    
    * parse.y: `do` after cmdarg in parentheses should be `do_block`
      and bound to the outer method.  [ruby-core:72482] [Bug #11873]

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
    trunk/test/ruby/test_syntax.rb
Index: test/ruby/test_syntax.rb
===================================================================
--- test/ruby/test_syntax.rb	(revision 56197)
+++ test/ruby/test_syntax.rb	(revision 56198)
@@ -832,6 +832,14 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L832
     assert_valid_syntax("foo (bar rescue nil)")
   end
 
+  def test_cmdarg_in_paren
+    bug11873 = '[ruby-core:72482] [Bug #11873]'
+    assert_valid_syntax %q{a b{c d}, :e do end}, bug11873
+    assert_valid_syntax %q{a b(c d), :e do end}, bug11873
+    assert_valid_syntax %q{a b{c(d)}, :e do end}, bug11873
+    assert_valid_syntax %q{a b(c(d)), :e do end}, bug11873
+  end
+
   private
 
   def not_label(x) @result = x; @not_label ||= nil end
Index: parse.y
===================================================================
--- parse.y	(revision 56197)
+++ parse.y	(revision 56198)
@@ -7911,7 +7911,7 @@ parse_ident(struct parser_params *parser https://github.com/ruby/ruby/blob/trunk/parse.y#L7911
 		if (COND_P()) return keyword_do_cond;
 		if (CMDARG_P() && !IS_lex_state_for(state, EXPR_CMDARG))
 		    return keyword_do_block;
-		if (IS_lex_state_for(state, (EXPR_BEG | EXPR_ENDARG)))
+		if (IS_lex_state_for(state, (EXPR_BEG | EXPR_END | EXPR_ENDARG)))
 		    return keyword_do_block;
 		return keyword_do;
 	    }
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 56197)
+++ ChangeLog	(revision 56198)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Sep 21 13:38:44 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y: `do` after cmdarg in parentheses should be `do_block`
+	  and bound to the outer method.  [ruby-core:72482] [Bug #11873]
+
 Wed Sep 21 13:32:00 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* parse.y (brace_body, do_body): extract block bodies.

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

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