mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* compile.c (iseq_compile_each), parse.y (stmt, arg): arg_concat()
on op_asgn was inversed. [ruby-core:25629] [Bug #2050] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6200f424a7
commit
8686840960
4 changed files with 19 additions and 6 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri Sep 18 16:15:04 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* compile.c (iseq_compile_each), parse.y (stmt, arg): arg_concat()
|
||||
on op_asgn was inversed. [ruby-core:25629] [Bug #2050]
|
||||
|
||||
Fri Sep 18 16:06:27 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* dir.c (GlobPathValue): glob allows null bytes as separators.
|
||||
|
|
|
@ -3760,9 +3760,9 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
ADD_INSN(ret, nd_line(node), putnil);
|
||||
}
|
||||
COMPILE(ret, "NODE_OP_ASGN1 recv", node->nd_recv);
|
||||
if (nd_type(node->nd_args->nd_body) != NODE_ZARRAY) {
|
||||
if (nd_type(node->nd_args->nd_head) != NODE_ZARRAY) {
|
||||
INIT_ANCHOR(args);
|
||||
argc = setup_args(iseq, args, node->nd_args->nd_body, &flag);
|
||||
argc = setup_args(iseq, args, node->nd_args->nd_head, &flag);
|
||||
ADD_SEQ(ret, args);
|
||||
}
|
||||
else {
|
||||
|
@ -3795,7 +3795,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
}
|
||||
ADD_INSN(ret, nd_line(node), pop);
|
||||
|
||||
COMPILE(ret, "NODE_OP_ASGN1 args->head: ", node->nd_args->nd_head);
|
||||
COMPILE(ret, "NODE_OP_ASGN1 args->body: ", node->nd_args->nd_body);
|
||||
if (!poped) {
|
||||
ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 2));
|
||||
}
|
||||
|
@ -3819,7 +3819,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
ADD_LABEL(ret, lfin);
|
||||
}
|
||||
else {
|
||||
COMPILE(ret, "NODE_OP_ASGN1 args->head: ", node->nd_args->nd_head);
|
||||
COMPILE(ret, "NODE_OP_ASGN1 args->body: ", node->nd_args->nd_body);
|
||||
ADD_SEND(ret, nd_line(node), ID2SYM(id), INT2FIX(1));
|
||||
if (!poped) {
|
||||
ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 2));
|
||||
|
|
4
parse.y
4
parse.y
|
@ -1050,7 +1050,7 @@ stmt : keyword_alias fitem {lex_state = EXPR_FNAME;} fitem
|
|||
|
||||
value_expr($6);
|
||||
if (!$3) $3 = NEW_ZARRAY();
|
||||
args = arg_concat($6, $3);
|
||||
args = arg_concat($3, $6);
|
||||
if ($5 == tOROP) {
|
||||
$5 = 0;
|
||||
}
|
||||
|
@ -1884,7 +1884,7 @@ arg : lhs '=' arg
|
|||
|
||||
value_expr($6);
|
||||
if (!$3) $3 = NEW_ZARRAY();
|
||||
args = arg_concat($6, $3);
|
||||
args = arg_concat($3, $6);
|
||||
if ($5 == tOROP) {
|
||||
$5 = 0;
|
||||
}
|
||||
|
|
|
@ -77,6 +77,14 @@ class TestAssignment < Test::Unit::TestCase
|
|||
a,b,*c = *[*[]]; assert_equal([nil,nil,[]], [a,b,c])
|
||||
a,b,*c = *[*[1]]; assert_equal([1,nil,[]], [a,b,c])
|
||||
a,b,*c = *[*[1,2]]; assert_equal([1,2,[]], [a,b,c])
|
||||
|
||||
bug2050 = '[ruby-core:25629]'
|
||||
a = Hash.new {[]}
|
||||
b = [1, 2]
|
||||
assert_equal([1, 2, 3], a[:x] += [*b, 3], bug2050)
|
||||
assert_equal([1, 2, 3], a[:x], bug2050)
|
||||
assert_equal([1, 2, 3, [1, 2, 3]], a[:x] <<= [*b, 3], bug2050)
|
||||
assert_equal([1, 2, 3, [1, 2, 3]], a[:x], bug2050)
|
||||
end
|
||||
|
||||
def test_yield
|
||||
|
|
Loading…
Reference in a new issue