From 43bbe2841daf838111aa3f2687c23506191e76e7 Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 3 Jul 2007 19:11:49 +0000 Subject: * compile.c (compile_array): ignore NODE_ZARRAY. [ruby-dev:31110] * bootstraptest/test_method.rb: add a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ bootstraptest/test_method.rb | 15 +++++++++++++++ compile.c | 22 ++++++++++++---------- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8d87dc9ba9..fffc2906ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Jul 4 04:07:00 2007 Koichi Sasada + + * compile.c (compile_array): ignore NODE_ZARRAY. + [ruby-dev:31110] + + * bootstraptest/test_method.rb: add a test for above. + Wed Jul 4 04:04:02 2007 Koichi Sasada * compile.h: fix debug print level. diff --git a/bootstraptest/test_method.rb b/bootstraptest/test_method.rb index c95eec175e..7f20bf5a95 100644 --- a/bootstraptest/test_method.rb +++ b/bootstraptest/test_method.rb @@ -336,6 +336,21 @@ assert_equal '[[:ok1, :foo], [:ok2, :foo, :bar]]', $ary } +# with +assert_equal '[:ok1, [:ok2, 11]]', %q{ + class C + def [] + $ary << :ok1 + 10 + end + def []=(a) + $ary << [:ok2, a] + end + end + $ary = [] + C.new[]+=1 + $ary +} # splat and block arguments assert_equal %q{[[[:x, :y, :z], NilClass], [[1, :x, :y, :z], NilClass], [[1, 2, :x, :y, :z], NilClass], [[:obj], NilClass], [[1, :obj], NilClass], [[1, 2, :obj], NilClass], [[], Proc], [[1], Proc], [[1, 2], Proc], [[], Proc], [[1], Proc], [[1, 2], Proc], [[:x, :y, :z], Proc], [[1, :x, :y, :z], Proc], [[1, 2, :x, :y, :z], Proc]]}, %q{ diff --git a/compile.c b/compile.c index 02f2214940..73b761c2dc 100644 --- a/compile.c +++ b/compile.c @@ -1831,18 +1831,20 @@ compile_array(rb_iseq_t *iseq, int len = node->nd_alen, line = nd_line(node), i=0; DECL_ANCHOR(anchor); - while (node) { - if (nd_type(node) != NODE_ARRAY) { - rb_bug("compile_array: This node is not NODE_ARRAY, but %s", - ruby_node_name(nd_type(node))); - } + if (nd_type(node) != NODE_ZARRAY) { + while (node) { + if (nd_type(node) != NODE_ARRAY) { + rb_bug("compile_array: This node is not NODE_ARRAY, but %s", + ruby_node_name(nd_type(node))); + } - i++; - if (opt_p && nd_type(node->nd_head) != NODE_LIT) { - opt_p = Qfalse; + i++; + if (opt_p && nd_type(node->nd_head) != NODE_LIT) { + opt_p = Qfalse; + } + COMPILE(anchor, "array element", node->nd_head); + node = node->nd_next; } - COMPILE(anchor, "array element", node->nd_head); - node = node->nd_next; } if (len != i) { -- cgit v1.2.3