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

ruby-changes:33329

From: nobu <ko1@a...>
Date: Tue, 25 Mar 2014 23:57:26 +0900 (JST)
Subject: [ruby-changes:33329] nobu:r45408 (trunk): parse.y: required kwarg without parentheses

nobu	2014-03-25 23:57:18 +0900 (Tue, 25 Mar 2014)

  New Revision: 45408

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

  Log:
    parse.y: required kwarg without parentheses
    
    * parse.y (parser_yylex): only a newline after label should be
      significant.  [ruby-core:61658] [Bug #9669]

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
    trunk/test/ruby/test_keyword.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45407)
+++ ChangeLog	(revision 45408)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Mar 25 23:57:17 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (parser_yylex): only a newline after label should be
+	  significant.  [ruby-core:61658] [Bug #9669]
+
 Tue Mar 25 23:32:25 2014  Kazuhiro NISHIYAMA  <zn@m...>
 
 	* ext/pathname/lib/pathname.rb (Pathname#join): remove unnecessary
Index: parse.y
===================================================================
--- parse.y	(revision 45407)
+++ parse.y	(revision 45408)
@@ -7017,13 +7017,16 @@ parser_yylex(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L7017
 #endif
 	/* fall through */
       case '\n':
-	if (IS_lex_state(EXPR_BEG | EXPR_VALUE | EXPR_CLASS | EXPR_FNAME | EXPR_DOT)) {
+	if (IS_lex_state(EXPR_BEG | EXPR_VALUE | EXPR_CLASS | EXPR_FNAME | EXPR_DOT | EXPR_LABELARG)) {
 #ifdef RIPPER
             if (!fallthru) {
                 ripper_dispatch_scan_event(parser, tIGNORED_NL);
             }
             fallthru = FALSE;
 #endif
+	    if (IS_lex_state(EXPR_LABELARG) && parser->parser_in_kwarg) {
+		goto normal_newline;
+	    }
 	    goto retry;
 	}
 	while ((c = nextc())) {
Index: test/ruby/test_keyword.rb
===================================================================
--- test/ruby/test_keyword.rb	(revision 45407)
+++ test/ruby/test_keyword.rb	(revision 45408)
@@ -335,6 +335,15 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L335
       end;
     end
     assert_equal(42, bug9669.foo(a: 42))
+    assert_nothing_raised(SyntaxError, bug9669) do
+      eval(<<-'end;', nil, __FILE__, __LINE__)
+        o = {
+          a:
+          1
+        }
+      end;
+    end
+    assert_equal({a: 1}, o, bug9669)
   end
 
   def test_block_required_keyword

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

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