* compile.c (iseq_compile_each): to_a method should be called.
[Bug #3658] * compile.c (iseq_compile_each): ditto for ARGSPUSH. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3a32ef53aa
commit
600601c338
@ -1,3 +1,10 @@
|
|||||||
|
Thu Aug 5 20:30:39 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* compile.c (iseq_compile_each): to_a method should be called.
|
||||||
|
[Bug #3658]
|
||||||
|
|
||||||
|
* compile.c (iseq_compile_each): ditto for ARGSPUSH.
|
||||||
|
|
||||||
Thu Aug 5 20:13:49 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Aug 5 20:13:49 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* README.EXT, README.EXT.ja (String functions): mention
|
* README.EXT, README.EXT.ja (String functions): mention
|
||||||
|
15
compile.c
15
compile.c
@ -4522,14 +4522,23 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||||||
}
|
}
|
||||||
case NODE_ARGSCAT:{
|
case NODE_ARGSCAT:{
|
||||||
COMPILE_(ret, "argscat head", node->nd_head, poped);
|
COMPILE_(ret, "argscat head", node->nd_head, poped);
|
||||||
COMPILE_(ret, "argscat body", node->nd_body, poped);
|
COMPILE(ret, "argscat body", node->nd_body);
|
||||||
if (poped) break;
|
if (poped) {
|
||||||
|
ADD_INSN1(ret, nd_line(node), splatarray, Qfalse);
|
||||||
|
ADD_INSN(ret, nd_line(node), pop);
|
||||||
|
break;
|
||||||
|
}
|
||||||
ADD_INSN(ret, nd_line(node), concatarray);
|
ADD_INSN(ret, nd_line(node), concatarray);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NODE_ARGSPUSH:{
|
case NODE_ARGSPUSH:{
|
||||||
COMPILE(ret, "arsgpush head", node->nd_head);
|
COMPILE_(ret, "arsgpush head", node->nd_head, poped);
|
||||||
COMPILE(ret, "argspush body", node->nd_body);
|
COMPILE(ret, "argspush body", node->nd_body);
|
||||||
|
if (poped) {
|
||||||
|
ADD_INSN1(ret, nd_line(node), splatarray, Qfalse);
|
||||||
|
ADD_INSN(ret, nd_line(node), pop);
|
||||||
|
break;
|
||||||
|
}
|
||||||
ADD_INSN1(ret, nd_line(node), newarray, INT2FIX(1));
|
ADD_INSN1(ret, nd_line(node), newarray, INT2FIX(1));
|
||||||
ADD_INSN(ret, nd_line(node), concatarray);
|
ADD_INSN(ret, nd_line(node), concatarray);
|
||||||
break;
|
break;
|
||||||
|
@ -405,5 +405,20 @@ class TestRubyPrimitive < Test::Unit::TestCase
|
|||||||
bug3658 = '[ruby-dev:41933]'
|
bug3658 = '[ruby-dev:41933]'
|
||||||
[0, *x=1]
|
[0, *x=1]
|
||||||
assert_equal(1, x, bug3658)
|
assert_equal(1, x, bug3658)
|
||||||
|
[0, *x=1, 2]
|
||||||
|
assert_equal(1, x, bug3658)
|
||||||
|
class << (x = Object.new)
|
||||||
|
attr_accessor :to_a_called
|
||||||
|
def to_a
|
||||||
|
@to_a_called = true
|
||||||
|
[self]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
x.to_a_called = false
|
||||||
|
[0, *x]
|
||||||
|
assert(x.to_a_called, bug3658)
|
||||||
|
x.to_a_called = false
|
||||||
|
[0, *x, 2]
|
||||||
|
assert(x.to_a_called, bug3658)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user