summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c58
1 files changed, 27 insertions, 31 deletions
diff --git a/eval.c b/eval.c
index 498182de1d..1f408a0559 100644
--- a/eval.c
+++ b/eval.c
@@ -2222,6 +2222,25 @@ svalue_to_avalue(v)
}
static VALUE
+svalue_to_mrhs(v, lhs)
+ VALUE v;
+ NODE *lhs;
+{
+ VALUE tmp;
+
+ if (v == Qundef) return rb_ary_new2(0);
+ tmp = rb_check_array_type(v);
+
+ if (NIL_P(tmp)) {
+ return rb_ary_new3(1, v);
+ }
+ if (!lhs && RARRAY(tmp)->len <= 1) {
+ return rb_ary_new3(1, tmp);
+ }
+ return tmp;
+}
+
+static VALUE
class_prefix(self, cpath)
VALUE self;
NODE *cpath;
@@ -2978,7 +2997,7 @@ rb_eval(self, n)
break;
case NODE_MASGN:
- result = svalue_to_avalue(rb_eval(self, node->nd_value));
+ result = svalue_to_mrhs(rb_eval(self, node->nd_value), node->nd_head);
result = massign(self, node, result, 0);
break;
@@ -3910,7 +3929,9 @@ rb_yield_0(val, self, klass, pcall, avalue)
}
}
else if (nd_type(block->var) == NODE_MASGN) {
- if (!avalue) val = svalue_to_avalue(val);
+ if (!avalue) {
+ val = svalue_to_mrhs(val, block->var->nd_head);
+ }
massign(self, block->var, val, pcall);
}
else {
@@ -4024,34 +4045,13 @@ massign(self, node, val, pcall)
int pcall;
{
NODE *list;
- VALUE tmp;
long i = 0, len;
len = RARRAY(val)->len;
list = node->nd_head;
- if (len == 1 && list) {
- VALUE v = RARRAY(val)->ptr[0];
- tmp = rb_check_array_type(v);
-
- if (NIL_P(tmp)) {
- assign(self, list->nd_head, v, pcall);
- list = list->nd_next;
- i = 1;
- }
- else {
- len = RARRAY(tmp)->len;
- for (i=0; list && i<len; i++) {
- assign(self, list->nd_head, RARRAY(tmp)->ptr[i], pcall);
- list = list->nd_next;
- }
- }
- }
- else {
- for (; list && i<len; i++) {
- assign(self, list->nd_head, RARRAY(val)->ptr[i], pcall);
- list = list->nd_next;
- }
- tmp = val;
+ for (; list && i<len; i++) {
+ assign(self, list->nd_head, RARRAY(val)->ptr[i], pcall);
+ list = list->nd_next;
}
if (pcall && list) goto arg_error;
if (node->nd_args) {
@@ -4059,7 +4059,7 @@ massign(self, node, val, pcall)
/* no check for mere `*' */
}
else if (!list && i<len) {
- assign(self, node->nd_args, rb_ary_new4(len-i, RARRAY(tmp)->ptr+i), pcall);
+ assign(self, node->nd_args, rb_ary_new4(len-i, RARRAY(val)->ptr+i), pcall);
}
else {
assign(self, node->nd_args, rb_ary_new2(0), pcall);
@@ -6691,7 +6691,6 @@ proc_invoke(proc, args, pcall, self)
PUSH_ITER(ITER_CUR);
ruby_frame->iter = ITER_CUR;
-
PUSH_TAG(PROT_NONE);
state = EXEC_TAG();
if (state == 0) {
@@ -6713,9 +6712,6 @@ proc_invoke(proc, args, pcall, self)
case 0:
break;
case TAG_BREAK:
- if (!pcall && orphan) {
- localjump_error("break from proc-closure", prot_tag->retval);
- }
result = prot_tag->retval;
break;
case TAG_RETRY: