summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-06 17:59:53 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-06 17:59:53 +0000
commit8a4abe47cacd613a2d77287df75245fef6693246 (patch)
treee16415a5c89603a9adb4f968996d79f559c0f157
parent0dd4fde745f2c33a473ea3ee54b01a1d24d4586c (diff)
* parse.y (stmt): rhs of multiple assignment should not be
expanded using "to_a". [ruby-dev:21527] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--eval.c67
-rw-r--r--gc.c1
-rw-r--r--node.h2
-rw-r--r--parse.y4
5 files changed, 44 insertions, 35 deletions
diff --git a/ChangeLog b/ChangeLog
index c5b58b16d0..85ca8029f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Oct 7 02:57:53 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (stmt): rhs of multiple assignment should not be
+ expanded using "to_a". [ruby-dev:21527]
+
Tue Oct 7 01:42:34 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_asn1.c (ossl_asn1_get_asn1type): use appropriate
diff --git a/eval.c b/eval.c
index 6114efa7e0..bdd71486f5 100644
--- a/eval.c
+++ b/eval.c
@@ -2774,6 +2774,10 @@ rb_eval(self, n)
result = splat_value(rb_eval(self, node->nd_head));
break;
+ case NODE_TO_ARY:
+ result = rb_ary_to_ary(rb_eval(self, node->nd_head));
+ break;
+
case NODE_SVALUE:
result = avalue_splat(rb_eval(self, node->nd_head));
if (result == Qundef) result = Qnil;
@@ -6483,45 +6487,42 @@ rb_f_at_exit()
void
rb_exec_end_proc()
{
- struct end_proc_data *link, *save;
+ struct end_proc_data *link, *tmp;
int status;
- save = link = end_procs;
- while (link) {
- PUSH_TAG(PROT_NONE);
- if ((status = EXEC_TAG()) == 0) {
- (*link->func)(link->data);
- }
- POP_TAG();
- if (status) {
- error_handle(status);
- }
- link = link->next;
- }
- link = end_procs;
- while (link != save) {
- PUSH_TAG(PROT_NONE);
- if ((status = EXEC_TAG()) == 0) {
- (*link->func)(link->data);
- }
- POP_TAG();
- if (status) {
- error_handle(status);
- }
- link = link->next;
- }
while (ephemeral_end_procs) {
link = ephemeral_end_procs;
- ephemeral_end_procs = link->next;
- PUSH_TAG(PROT_NONE);
- if ((status = EXEC_TAG()) == 0) {
- (*link->func)(link->data);
+ ephemeral_end_procs = 0;
+ while (link) {
+ PUSH_TAG(PROT_NONE);
+ if ((status = EXEC_TAG()) == 0) {
+ (*link->func)(link->data);
+ }
+ POP_TAG();
+ if (status) {
+ error_handle(status);
+ }
+ tmp = link;
+ link = link->next;
+ free(tmp);
}
- POP_TAG();
- if (status) {
- error_handle(status);
+ }
+ while (end_procs) {
+ link = end_procs;
+ end_procs = 0;
+ while (link) {
+ PUSH_TAG(PROT_NONE);
+ if ((status = EXEC_TAG()) == 0) {
+ (*link->func)(link->data);
+ }
+ POP_TAG();
+ if (status) {
+ error_handle(status);
+ }
+ tmp = link;
+ link = link->next;
+ free(tmp);
}
- free(link);
}
}
diff --git a/gc.c b/gc.c
index 0eb2e096c7..b3200d2927 100644
--- a/gc.c
+++ b/gc.c
@@ -755,6 +755,7 @@ rb_gc_mark_children(ptr)
case NODE_COLON2:
case NODE_ARGS:
case NODE_SPLAT:
+ case NODE_TO_ARY:
case NODE_SVALUE:
ptr = (VALUE)obj->as.node.u1.node;
goto again;
diff --git a/node.h b/node.h
index f73c738304..0e5150ced9 100644
--- a/node.h
+++ b/node.h
@@ -88,6 +88,7 @@ enum node_type {
NODE_ARGSCAT,
NODE_ARGSPUSH,
NODE_SPLAT,
+ NODE_TO_ARY,
NODE_SVALUE,
NODE_BLOCK_ARG,
NODE_BLOCK_PASS,
@@ -308,6 +309,7 @@ typedef struct RNode {
#define NEW_ARGSCAT(a,b) NEW_NODE(NODE_ARGSCAT,a,b,0)
#define NEW_ARGSPUSH(a,b) NEW_NODE(NODE_ARGSPUSH,a,b,0)
#define NEW_SPLAT(a) NEW_NODE(NODE_SPLAT,a,0,0)
+#define NEW_TO_ARY(a) NEW_NODE(NODE_TO_ARY,a,0,0)
#define NEW_SVALUE(a) NEW_NODE(NODE_SVALUE,a,0,0)
#define NEW_BLOCK_ARG(v) NEW_NODE(NODE_BLOCK_ARG,v,0,local_cnt(v))
#define NEW_BLOCK_PASS(b) NEW_NODE(NODE_BLOCK_PASS,0,b,0)
diff --git a/parse.y b/parse.y
index 7005602010..59ef2a891f 100644
--- a/parse.y
+++ b/parse.y
@@ -486,7 +486,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
| mlhs '=' command_call
{
value_expr($3);
- $1->nd_value = ($1->nd_head) ? NEW_SPLAT($3) : NEW_ARRAY($3);
+ $1->nd_value = NEW_TO_ARY($3);
$$ = $1;
}
| var_lhs tOP_ASGN command_call
@@ -578,7 +578,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
}
| mlhs '=' arg_value
{
- $1->nd_value = ($1->nd_head) ? NEW_SPLAT($3) : NEW_ARRAY($3);
+ $1->nd_value = NEW_TO_ARY($3);
$$ = $1;
}
| mlhs '=' mrhs