aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-21 20:45:35 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-21 20:45:35 +0000
commit3337185ed683bfc82f86641e0627021952cefa8b (patch)
tree2fe4e0593d2edeab36292edbce28d7b32f69911c
parentfa127bbb189a88921870ccd922744a7aa14aa009 (diff)
downloadruby-3337185ed683bfc82f86641e0627021952cefa8b.tar.gz
* parse.y (arg_concat_gen): concat target node should be NODE_ARRAY.
[ruby-core:19413] * bootstraptest/test_method.rb: add tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--bootstraptest/test_method.rb15
-rw-r--r--parse.y6
2 files changed, 18 insertions, 3 deletions
diff --git a/bootstraptest/test_method.rb b/bootstraptest/test_method.rb
index 63c6ad2db1..33e7436e6e 100644
--- a/bootstraptest/test_method.rb
+++ b/bootstraptest/test_method.rb
@@ -1069,3 +1069,18 @@ assert_equal 'ok', %q{
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)
+}
diff --git a/parse.y b/parse.y
index da63620f49..54e0c6ab8a 100644
--- a/parse.y
+++ b/parse.y
@@ -2443,8 +2443,7 @@ args : arg_value
{
/*%%%*/
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 @@ arg_concat_gen(struct parser_params *parser, NODE *node1, NODE *node2)
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;
}