ruby-changes:2542
From: ko1@a...
Date: 27 Nov 2007 15:55:12 +0900
Subject: [ruby-changes:2542] ko1 - Ruby:r14033 (trunk): * compile.c (iseq_compile_each): "when *[],1" dumps core.
ko1 2007-11-27 15:54:58 +0900 (Tue, 27 Nov 2007) New Revision: 14033 Modified files: trunk/ChangeLog trunk/bootstraptest/test_syntax.rb trunk/compile.c Log: * 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. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/compile.c?r1=14033&r2=14032 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14033&r2=14032 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/bootstraptest/test_syntax.rb?r1=14033&r2=14032 Index: ChangeLog =================================================================== --- ChangeLog (revision 14032) +++ ChangeLog (revision 14033) @@ -1,3 +1,10 @@ +Tue Nov 27 15:53:43 2007 Koichi Sasada <ko1@a...> + + * 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@a...> * compile.c (iseq_compile_each): "a[*b] += 1" dumps core. Index: bootstraptest/test_syntax.rb =================================================================== --- bootstraptest/test_syntax.rb (revision 14032) +++ bootstraptest/test_syntax.rb (revision 14033) @@ -612,3 +612,15 @@ a = [0] a[*a]+=1 } +assert_equal '2', %q{ + ary = [0] + case 1 + when *ary, 1 + 1 + end + + case + when *ary + 1 + end +} + Index: compile.c =================================================================== --- compile.c (revision 14032) +++ compile.c (revision 14033) @@ -2673,11 +2673,14 @@ 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 @@ 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 @@ 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; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml