summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--bootstraptest/test_syntax.rb12
-rw-r--r--compile.c18
3 files changed, 31 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 5abd9df527..bd360cfea5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* compile.c (iseq_compile_each): "a[*b] += 1" dumps core.
diff --git a/bootstraptest/test_syntax.rb b/bootstraptest/test_syntax.rb
index 5c45c95f94..b25d0d43c9 100644
--- a/bootstraptest/test_syntax.rb
+++ b/bootstraptest/test_syntax.rb
@@ -612,3 +612,15 @@ assert_equal '1', %q{
a = [0]
a[*a]+=1
}
+assert_equal '2', %q{
+ ary = [0]
+ case 1
+ when *ary, 1
+ 1
+ end +
+ case
+ when *ary
+ 1
+ end
+}
+
diff --git a/compile.c b/compile.c
index 9192792501..d100bad484 100644
--- a/compile.c
+++ b/compile.c
@@ -2673,11 +2673,14 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
if (nd_type(vals) == NODE_ARRAY) {
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;
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);
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);
}
else {
- rb_bug("NODE_CASAE: unknown node (%s)",
+ rb_bug("NODE_CASE: unknown node (%s)",
ruby_node_name(nd_type(vals)));
}
}
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;
@@ -2755,10 +2758,13 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
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;
- if (nd_type(vals) == NODE_ARGSCAT) {
+ if (nd_type(vals) == NODE_ARGSCAT || nd_type(vals) == NODE_ARGSPUSH) {
NODE *vs = vals->nd_head;
val = vals->nd_body;