mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* compile.c (NODE_ARGSCAT, NODE_ARGSPUSH): drop unused ARGSCAT
results when poped is true. [ruby-dev:41933], [Bug #3658] This is retry of r28870 and r28873 which were reverted. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fa9d53d00f
commit
5ffe59faf8
3 changed files with 51 additions and 7 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Thu Aug 5 21:20:31 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
|
* compile.c (NODE_ARGSCAT, NODE_ARGSPUSH): drop unused ARGSCAT
|
||||||
|
results when poped is true. [ruby-dev:41933], [Bug #3658]
|
||||||
|
This is retry of r28870 and r28873 which were reverted.
|
||||||
|
|
||||||
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
|
||||||
|
|
20
compile.c
20
compile.c
|
@ -4521,16 +4521,34 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NODE_ARGSCAT:{
|
case NODE_ARGSCAT:{
|
||||||
|
if (poped) {
|
||||||
|
COMPILE(ret, "argscat head", node->nd_head);
|
||||||
|
ADD_INSN1(ret, nd_line(node), splatarray, Qfalse);
|
||||||
|
ADD_INSN(ret, nd_line(node), pop);
|
||||||
|
COMPILE(ret, "argscat body", node->nd_body);
|
||||||
|
ADD_INSN1(ret, nd_line(node), splatarray, Qfalse);
|
||||||
|
ADD_INSN(ret, nd_line(node), pop);
|
||||||
|
}
|
||||||
|
else {
|
||||||
COMPILE(ret, "argscat head", node->nd_head);
|
COMPILE(ret, "argscat head", node->nd_head);
|
||||||
COMPILE(ret, "argscat body", node->nd_body);
|
COMPILE(ret, "argscat body", node->nd_body);
|
||||||
ADD_INSN(ret, nd_line(node), concatarray);
|
ADD_INSN(ret, nd_line(node), concatarray);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NODE_ARGSPUSH:{
|
case NODE_ARGSPUSH:{
|
||||||
|
if (poped) {
|
||||||
COMPILE(ret, "arsgpush head", node->nd_head);
|
COMPILE(ret, "arsgpush head", node->nd_head);
|
||||||
COMPILE(ret, "argspush body", node->nd_body);
|
ADD_INSN1(ret, nd_line(node), splatarray, Qfalse);
|
||||||
|
ADD_INSN(ret, nd_line(node), pop);
|
||||||
|
COMPILE_(ret, "argspush body", node->nd_body, poped);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
COMPILE(ret, "arsgpush head", node->nd_head);
|
||||||
|
COMPILE_(ret, "argspush body", node->nd_body, poped);
|
||||||
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;
|
||||||
}
|
}
|
||||||
case NODE_SPLAT:{
|
case NODE_SPLAT:{
|
||||||
|
|
|
@ -400,4 +400,24 @@ class TestRubyPrimitive < Test::Unit::TestCase
|
||||||
#assert_equal [0,1,2,3,4], [0, *a, 4]
|
#assert_equal [0,1,2,3,4], [0, *a, 4]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_concatarray_ruby_dev_41933
|
||||||
|
bug3658 = '[ruby-dev:41933]'
|
||||||
|
[0, *x=1]
|
||||||
|
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue