summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-08-27 19:43:50 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-08-27 19:43:50 +0000
commit22b955d9bff9f736af9e81ca5e49bad6608cb987 (patch)
tree62a57247ab89ca7f486c74305258edd2db17fd69 /eval.c
parenta5729ea05a55c86142c57dbb176638c0e4f54cc6 (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 'eval.c')
-rw-r--r--eval.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/eval.c b/eval.c
index 38edb34856..5ee4158b27 100644
--- a/eval.c
+++ b/eval.c
@@ -2348,7 +2348,7 @@ svalue_to_mrhs(v, lhs)
return rb_ary_new3(1, v);
}
/* no lhs means splat lhs only */
- if (!lhs && RARRAY(tmp)->len <= 1) {
+ if (!lhs) {
return rb_ary_new3(1, v);
}
return tmp;
@@ -2399,8 +2399,8 @@ static VALUE
splat_value(v)
VALUE v;
{
- if (NIL_P(v)) return rb_ary_new3(1, Qnil);
- return rb_Array(v);
+ if (NIL_P(v)) return rb_ary_new3(1, Qnil);
+ return rb_Array(v);
}
static VALUE
@@ -2784,17 +2784,12 @@ rb_eval(self, n)
JUMP_TAG(TAG_RETRY);
break;
- case NODE_RESTARY:
- case NODE_RESTARY2:
- result = splat_value(rb_eval(self, node->nd_head));
- break;
-
case NODE_SPLAT:
- result = avalue_splat(splat_value(rb_eval(self, node->nd_head)));
+ result = splat_value(rb_eval(self, node->nd_head));
break;
case NODE_SVALUE:
- result = rb_eval(self, node->nd_head);
+ result = avalue_splat(rb_eval(self, node->nd_head));
if (result == Qundef) result = Qnil;
break;
@@ -3157,8 +3152,7 @@ rb_eval(self, n)
break;
case NODE_MASGN:
- result = svalue_to_mrhs(rb_eval(self, node->nd_value), node->nd_head);
- result = massign(self, node, result, 0);
+ result = massign(self, node, rb_eval(self, node->nd_value), 0);
break;
case NODE_LASGN: