diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-08-27 19:43:50 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-08-27 19:43:50 +0000 |
commit | 22b955d9bff9f736af9e81ca5e49bad6608cb987 (patch) | |
tree | 62a57247ab89ca7f486c74305258edd2db17fd69 /parse.y | |
parent | a5729ea05a55c86142c57dbb176638c0e4f54cc6 (diff) |
* eval.c (rb_eval): *a = [1,2] now assigns [[1,2]] to a.
consistent with *a = [1], which set [[1]] to a.
* node.h: merge NODE_RESTARY to NODE_SPLAT.
* parse.y: rules simplified a bit by removing NODE_RESTARY.
* sample/test.rb: updated for new assignment behavior.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 22 |
1 files changed, 10 insertions, 12 deletions
@@ -491,7 +491,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem | mlhs '=' command_call { value_expr($3); - $1->nd_value = NEW_RESTARY($3); + $1->nd_value = ($1->nd_head) ? NEW_SPLAT($3) : NEW_ARRAY($3); $$ = $1; } | var_lhs tOP_ASGN command_call @@ -583,7 +583,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem } | mlhs '=' arg_value { - $1->nd_value = $3; + $1->nd_value = ($1->nd_head) ? NEW_SPLAT($3) : NEW_ARRAY($3); $$ = $1; } | mlhs '=' mrhs @@ -1225,7 +1225,7 @@ aref_args : none | tSTAR arg opt_nl { value_expr($2); - $$ = NEW_RESTARY2($2); + $$ = NEW_BEGIN($2); } ; @@ -1290,7 +1290,7 @@ call_args : command } | tSTAR arg_value opt_block_arg { - $$ = arg_blk_pass(NEW_RESTARY($2), $3); + $$ = arg_blk_pass(NEW_SPLAT($2), $3); } | block_arg ; @@ -1345,7 +1345,7 @@ call_args2 : arg_value ',' args opt_block_arg } | tSTAR arg_value opt_block_arg { - $$ = arg_blk_pass(NEW_RESTARY($2), $3); + $$ = arg_blk_pass(NEW_SPLAT($2), $3); } | block_arg ; @@ -5395,8 +5395,8 @@ ret_args(node) if (nd_type(node) == NODE_ARRAY && node->nd_next == 0) { node = node->nd_head; } - if (nd_type(node) == NODE_RESTARY) { - nd_set_type(node, NODE_SPLAT); + if (nd_type(node) == NODE_SPLAT) { + node = NEW_SVALUE(node); } } return node; @@ -5414,9 +5414,8 @@ new_yield(node) node = node->nd_head; state = Qfalse; } - if (nd_type(node) == NODE_RESTARY) { - nd_set_type(node, NODE_SPLAT); - state = Qfalse; + if (nd_type(node) == NODE_SPLAT) { + state = Qtrue; } } else { @@ -5465,8 +5464,7 @@ arg_prepend(node1, node2) case NODE_ARRAY: return list_concat(NEW_LIST(node1), node2); - case NODE_RESTARY: - case NODE_RESTARY2: + case NODE_SPLAT: return arg_concat(node1, node2->nd_head); case NODE_BLOCK_PASS: |