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

ruby-changes:14332

From: nobu <ko1@a...>
Date: Wed, 23 Dec 2009 20:49:06 +0900 (JST)
Subject: [ruby-changes:14332] Ruby:r26160 (ruby_1_8): * parse.y (args): splat other than direct array literal.

nobu	2009-12-23 20:48:55 +0900 (Wed, 23 Dec 2009)

  New Revision: 26160

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

  Log:
    * parse.y (args): splat other than direct array literal.
      [ruby-dev:39771]

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/parse.y
    branches/ruby_1_8/test/ruby/test_array.rb

Index: ruby_1_8/parse.y
===================================================================
--- ruby_1_8/parse.y	(revision 26159)
+++ ruby_1_8/parse.y	(revision 26160)
@@ -1455,7 +1455,7 @@
 		| tSTAR arg_value
 		    {
 		    /*%%%*/
-			$$ = splat_array($2);
+			if (!($$ = splat_array($2))) $$ = NEW_SPLAT($2);
 		    /*%
 			$$ = arg_add_star(arg_new(), $2);
 		    %*/
@@ -1569,14 +1569,15 @@
 		    {
 			$$ = NEW_COLON3($2);
 		    }
-		| tLBRACK aref_args ']'
+		| tLBRACK {$<num>$ = ruby_sourceline;} aref_args ']'
 		    {
-		        if ($2 == 0) {
+		        if ($3 == 0) {
 			    $$ = NEW_ZARRAY(); /* zero length array*/
 			}
 			else {
-			    $$ = $2;
+			    $$ = $3;
 			}
+			nd_set_line($$, $<num>2);
 		    }
 		| tLBRACE assoc_list '}'
 		    {
@@ -5312,6 +5313,7 @@
 splat_array(node)
     NODE* node;
 {
+    if (nd_type(node) == NODE_NEWLINE) node = node->nd_next;
     if (nd_type(node) == NODE_SPLAT) node = node->nd_head;
     if (nd_type(node) == NODE_ARRAY) return node;
     return 0;
Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 26159)
+++ ruby_1_8/ChangeLog	(revision 26160)
@@ -1,3 +1,8 @@
+Wed Dec 23 20:48:52 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (args): splat other than direct array literal.
+	  [ruby-dev:39771]
+
 Wed Dec 23 17:23:52 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* eval.c (rb_load): initialize orig_func.   [ruby-core:27296]
Index: ruby_1_8/test/ruby/test_array.rb
===================================================================
--- ruby_1_8/test/ruby/test_array.rb	(revision 26159)
+++ ruby_1_8/test/ruby/test_array.rb	(revision 26160)
@@ -1280,7 +1280,8 @@
   def test_splat
     a = [2,3]
     assert_equal([1,2,3], [1, *a])
+    bug2401 = '[ruby-dev:39771]'
     a = [2,3]
-    assert_equal([2,3], [*a])
+    assert_equal([2,3], [*a], bug2401)
   end
 end

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

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