summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compile.c8
-rw-r--r--spec/ruby/language/fixtures/send.rb3
-rw-r--r--spec/ruby/language/send_spec.rb1
-rw-r--r--test/ruby/test_assignment.rb8
4 files changed, 11 insertions, 9 deletions
diff --git a/compile.c b/compile.c
index cea09c8f8a..368a69853d 100644
--- a/compile.c
+++ b/compile.c
@@ -7104,8 +7104,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
CHECK(!NIL_P(argc));
}
ADD_INSN1(ret, line, dupn, FIXNUM_INC(argc, 1 + boff));
+ flag |= asgnflag;
ADD_SEND_WITH_FLAG(ret, line, idAREF, argc, INT2FIX(flag));
- flag |= asgnflag;
if (id == idOROP || id == idANDOP) {
/* a[x] ||= y or a[x] &&= y
@@ -7249,7 +7249,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
ADD_INSNL(ret, line, branchnil, lskip);
}
ADD_INSN(ret, line, dup);
- ADD_SEND(ret, line, vid, INT2FIX(0));
+ ADD_SEND_WITH_FLAG(ret, line, vid, INT2FIX(0), INT2FIX(asgnflag));
if (atype == idOROP || atype == idANDOP) {
ADD_INSN(ret, line, dup);
@@ -8257,7 +8257,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
ADD_INSN1(ret, line, topn, INT2FIX(1));
if (flag & VM_CALL_ARGS_SPLAT) {
ADD_INSN1(ret, line, putobject, INT2FIX(-1));
- ADD_SEND(ret, line, idAREF, INT2FIX(1));
+ ADD_SEND_WITH_FLAG(ret, line, idAREF, INT2FIX(1), INT2FIX(asgnflag));
}
ADD_INSN1(ret, line, setn, FIXNUM_INC(argc, 3));
ADD_INSN (ret, line, pop);
@@ -8265,7 +8265,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
else if (flag & VM_CALL_ARGS_SPLAT) {
ADD_INSN(ret, line, dup);
ADD_INSN1(ret, line, putobject, INT2FIX(-1));
- ADD_SEND(ret, line, idAREF, INT2FIX(1));
+ ADD_SEND_WITH_FLAG(ret, line, idAREF, INT2FIX(1), INT2FIX(asgnflag));
ADD_INSN1(ret, line, setn, FIXNUM_INC(argc, 2));
ADD_INSN (ret, line, pop);
}
diff --git a/spec/ruby/language/fixtures/send.rb b/spec/ruby/language/fixtures/send.rb
index c3013616b2..918241e171 100644
--- a/spec/ruby/language/fixtures/send.rb
+++ b/spec/ruby/language/fixtures/send.rb
@@ -53,8 +53,9 @@ module LangSendSpecs
end
class PrivateGetter
- attr_reader :foo
+ attr_accessor :foo
private :foo
+ private :foo=
def call_self_foo
self.foo
diff --git a/spec/ruby/language/send_spec.rb b/spec/ruby/language/send_spec.rb
index 290b8662db..5e6571893c 100644
--- a/spec/ruby/language/send_spec.rb
+++ b/spec/ruby/language/send_spec.rb
@@ -269,6 +269,7 @@ describe "Invoking a private getter method" do
it "permits self as a receiver" do
receiver = LangSendSpecs::PrivateGetter.new
-> { receiver.call_self_foo }.should_not raise_error(NoMethodError)
+ -> { receiver.call_self_foo_or_equals(6) }.should_not raise_error(NoMethodError)
end
end
end
diff --git a/test/ruby/test_assignment.rb b/test/ruby/test_assignment.rb
index c14568fde3..164d1cc1b5 100644
--- a/test/ruby/test_assignment.rb
+++ b/test/ruby/test_assignment.rb
@@ -133,17 +133,17 @@ class TestAssignment < Test::Unit::TestCase
assert_equal(1, o.instance_eval {self[0] = 1})
}
- assert_raise(NoMethodError, bug11096) {
+ assert_nothing_raised(NoMethodError) {
o.instance_eval {self.foo += 1}
}
- assert_raise(NoMethodError, bug11096) {
+ assert_nothing_raised(NoMethodError) {
o.instance_eval {self.foo &&= 1}
}
- assert_raise(NoMethodError, bug11096) {
+ assert_nothing_raised(NoMethodError) {
o.instance_eval {self[0] += 1}
}
- assert_raise(NoMethodError, bug11096) {
+ assert_nothing_raised(NoMethodError) {
o.instance_eval {self[0] &&= 1}
}
end