зеркало из https://github.com/github/ruby.git
* compile.c (iseq_compile_each): fix return value of obj[a,*b]=c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
becd789625
Коммит
021f166509
|
@ -1,3 +1,7 @@
|
|||
Fri Jun 17 18:57:36 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* compile.c (iseq_compile_each): fix return value of obj[a,*b]=c.
|
||||
|
||||
Fri Jun 17 13:09:45 2011 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* ext/curses/curses.c: Clean up documentation.
|
||||
|
|
|
@ -402,6 +402,10 @@ m(1,2,*ary,&b)
|
|||
$result
|
||||
}
|
||||
|
||||
# aset and splat
|
||||
assert_equal '4', %q{class Foo;def []=(a,b,c,d);end;end;Foo.new[1,*a=[2,3]]=4}
|
||||
assert_equal '4', %q{class Foo;def []=(a,b,c,d);end;end;def m(&blk)Foo.new[1,*a=[2,3],&blk]=4;end;m{}}
|
||||
|
||||
# post test
|
||||
assert_equal %q{[1, 2, :o1, :o2, [], 3, 4, NilClass, nil, nil]}, %q{
|
||||
def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2, &b)
|
||||
|
|
11
compile.c
11
compile.c
|
@ -4968,9 +4968,20 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
|
||||
if (flag & VM_CALL_ARGS_BLOCKARG_BIT) {
|
||||
ADD_INSN1(ret, nd_line(node), topn, INT2FIX(1));
|
||||
if (flag & VM_CALL_ARGS_SPLAT_BIT) {
|
||||
ADD_INSN1(ret, nd_line(node), putobject, INT2FIX(-1));
|
||||
ADD_SEND(ret, nd_line(node), ID2SYM(idAREF), INT2FIX(1));
|
||||
}
|
||||
ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 3));
|
||||
ADD_INSN (ret, nd_line(node), pop);
|
||||
}
|
||||
else if (flag & VM_CALL_ARGS_SPLAT_BIT) {
|
||||
ADD_INSN(ret, nd_line(node), dup);
|
||||
ADD_INSN1(ret, nd_line(node), putobject, INT2FIX(-1));
|
||||
ADD_SEND(ret, nd_line(node), ID2SYM(idAREF), INT2FIX(1));
|
||||
ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 2));
|
||||
ADD_INSN (ret, nd_line(node), pop);
|
||||
}
|
||||
else {
|
||||
ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 1));
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче