1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* compile.c (iseq_compile_each): "when *[],1" dumps core.

a patch from Yusuke ENDOH <mame AT tsg.ne.jp>.  [ruby-dev:32350]
* bootstraptest/test_syntax.rb: add a test for above.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2007-11-27 06:54:58 +00:00
parent 1bed0ccca8
commit 0cdd3bced5
3 changed files with 31 additions and 6 deletions

View file

@ -1,3 +1,10 @@
Tue Nov 27 15:53:43 2007 Koichi Sasada <ko1@atdot.net>
* compile.c (iseq_compile_each): "when *[],1" dumps core.
a patch from Yusuke ENDOH <mame AT tsg.ne.jp>. [ruby-dev:32350]
* bootstraptest/test_syntax.rb: add a test for above.
Tue Nov 27 15:40:05 2007 Koichi Sasada <ko1@atdot.net> Tue Nov 27 15:40:05 2007 Koichi Sasada <ko1@atdot.net>
* compile.c (iseq_compile_each): "a[*b] += 1" dumps core. * compile.c (iseq_compile_each): "a[*b] += 1" dumps core.

View file

@ -612,3 +612,15 @@ assert_equal '1', %q{
a = [0] a = [0]
a[*a]+=1 a[*a]+=1
} }
assert_equal '2', %q{
ary = [0]
case 1
when *ary, 1
1
end +
case
when *ary
1
end
}

View file

@ -2673,11 +2673,14 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
if (nd_type(vals) == NODE_ARRAY) { if (nd_type(vals) == NODE_ARRAY) {
special_literals = when_vals(iseq, cond_seq, vals, l1, special_literals); special_literals = when_vals(iseq, cond_seq, vals, l1, special_literals);
} }
else if (nd_type(vals) == NODE_SPLAT || nd_type(vals) == NODE_ARGSCAT) { else if (nd_type(vals) == NODE_SPLAT ||
nd_type(vals) == NODE_ARGSCAT ||
nd_type(vals) == NODE_ARGSPUSH) {
NODE *val = vals->nd_head; NODE *val = vals->nd_head;
special_literals = 0; special_literals = 0;
if (nd_type(vals) == NODE_ARGSCAT) { if (nd_type(vals) == NODE_ARGSCAT ||
nd_type(vals) == NODE_ARGSPUSH) {
when_vals(iseq, cond_seq, vals->nd_head, l1, 0); when_vals(iseq, cond_seq, vals->nd_head, l1, 0);
val = vals->nd_body; val = vals->nd_body;
} }
@ -2687,12 +2690,12 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
ADD_INSNL(cond_seq, nd_line(val), branchif, l1); ADD_INSNL(cond_seq, nd_line(val), branchif, l1);
} }
else { else {
rb_bug("NODE_CASAE: unknown node (%s)", rb_bug("NODE_CASE: unknown node (%s)",
ruby_node_name(nd_type(vals))); ruby_node_name(nd_type(vals)));
} }
} }
else { else {
rb_bug("NODE_CASAE: must be NODE_ARRAY, but 0"); rb_bug("NODE_CASE: must be NODE_ARRAY, but 0");
} }
node = node->nd_next; node = node->nd_next;
@ -2755,10 +2758,13 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
vals = vals->nd_next; vals = vals->nd_next;
} }
} }
else if (nd_type(vals) == NODE_SPLAT || nd_type(vals) == NODE_ARGSCAT) { else if (nd_type(vals) == NODE_SPLAT ||
nd_type(vals) == NODE_ARGSCAT ||
nd_type(vals) == NODE_ARGSPUSH) {
NODE *val = vals->nd_head; NODE *val = vals->nd_head;
if (nd_type(vals) == NODE_ARGSCAT) { if (nd_type(vals) == NODE_ARGSCAT || nd_type(vals) == NODE_ARGSPUSH) {
NODE *vs = vals->nd_head; NODE *vs = vals->nd_head;
val = vals->nd_body; val = vals->nd_body;