ruby-changes:8352
From: ko1 <ko1@a...>
Date: Wed, 22 Oct 2008 05:45:44 +0900 (JST)
Subject: [ruby-changes:8352] Ruby:r19880 (trunk): * parse.y (arg_concat_gen): concat target node should be NODE_ARRAY.
ko1 2008-10-22 05:45:35 +0900 (Wed, 22 Oct 2008) New Revision: 19880 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19880 Log: * parse.y (arg_concat_gen): concat target node should be NODE_ARRAY. [ruby-core:19413] * bootstraptest/test_method.rb: add tests. Modified files: trunk/bootstraptest/test_method.rb trunk/parse.y Index: bootstraptest/test_method.rb =================================================================== --- bootstraptest/test_method.rb (revision 19879) +++ bootstraptest/test_method.rb (revision 19880) @@ -1069,3 +1069,18 @@ break :ok end }, '[ruby-dev:36028]' + +assert_equal '[1, 2, [3, 4]]', %q{ + def regular(a, b, *c) + [a, b, c] + end + regular(*[], 1, *[], *[2, 3], *[], 4) +}, '[ruby-core:19413]' + +assert_equal '[1, [:foo, 3, 4, :foo]]', %q{ + def regular(a, *b) + [a, b] + end + a = b = [:foo] + regular(1, *a, *[3, 4], *b) +} Index: parse.y =================================================================== --- parse.y (revision 19879) +++ parse.y (revision 19880) @@ -2443,8 +2443,7 @@ { /*%%%*/ NODE *n1; - if (nd_type($4) == NODE_ARRAY && - (n1 = splat_array($1)) != 0) { + if ((nd_type($4) == NODE_ARRAY) && (n1 = splat_array($1)) != 0) { $$ = list_concat(n1, $4); } else { @@ -8131,7 +8130,8 @@ nd_set_type(node1, NODE_ARGSCAT); return node1; case NODE_ARGSCAT: - if (nd_type(node2) != NODE_ARRAY) break; + if (nd_type(node2) != NODE_ARRAY || + nd_type(node1->nd_body) != NODE_ARRAY) break; node1->nd_body = list_concat(node1->nd_body, node2); return node1; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/