1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

compile.c: assignment result of aset_with

* compile.c (iseq_compile_each): result of assignment should be
  its rhs instead of returned value from a method.
  [ruby-core:60071] [Bug #9448]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-01-25 05:21:07 +00:00
parent 7b8dc95b3a
commit 27dfc398a8
3 changed files with 21 additions and 3 deletions

View file

@ -1,3 +1,9 @@
Sat Jan 25 14:21:06 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* compile.c (iseq_compile_each): result of assignment should be
its rhs instead of returned value from a method.
[ruby-core:60071] [Bug #9448]
Sat Jan 25 11:16:19 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* class.c (rb_extract_keywords): treat nil keyword_hash same as 0,

View file

@ -5332,11 +5332,13 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
iseq_add_mark_object(iseq, str);
COMPILE(ret, "recv", node->nd_recv);
COMPILE(ret, "value", node->nd_args->nd_next->nd_head);
if (!poped) {
ADD_INSN(ret, line, swap);
ADD_INSN1(ret, line, topn, INT2FIX(1));
}
ADD_INSN2(ret, line, opt_aset_with,
new_callinfo(iseq, idASET, 2, 0, 0), str);
if (poped) {
ADD_INSN(ret, line, pop);
}
ADD_INSN(ret, line, pop);
break;
}

View file

@ -692,4 +692,14 @@ class TestAssignmentGen < Test::Unit::TestCase
check(assign)
}
end
def test_optimized_aset
bug9448 = Class.new do
def []=(key, new_value)
'[ruby-core:60071] [Bug #9448]'
end
end
o = bug9448.new
assert_equal("ok", o['current'] = "ok")
end
end