summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--compile.c11
-rw-r--r--test/ruby/test_assignment.rb2
3 files changed, 12 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 0eecdacedb..176ab25597 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Jul 19 12:40:50 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * compile.c (iseq_compile_each): allow to access private attribute
+ reader in op_assign. [ruby-core:63817] [Bug #10060]
+
Sat Jul 19 11:56:36 2014 Grey Baker <greysteil@gmail.com>
* lib/time.rb (Time#apply_offset): Guards against a `nil` return
diff --git a/compile.c b/compile.c
index 637e112b05..3e4f3f64de 100644
--- a/compile.c
+++ b/compile.c
@@ -4178,8 +4178,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
asgnflag = COMPILE_RECV(ret, "NODE_OP_ASGN2#recv", node);
ADD_INSN(ret, line, dup);
- ADD_SEND(ret, line, ID2SYM(node->nd_next->nd_vid),
- INT2FIX(0));
+ ADD_SEND_R(ret, line, ID2SYM(node->nd_next->nd_vid),
+ INT2FIX(0), Qfalse, INT2FIX(asgnflag));
if (atype == 0 || atype == 1) { /* 0: OR or 1: AND */
ADD_INSN(ret, line, dup);
@@ -5331,6 +5331,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
DECL_ANCHOR(args);
VALUE flag = 0;
VALUE argc;
+ int asgnflag;
/* optimization shortcut
* obj["literal"] = value -> opt_aset_with(obj, "literal", value)
@@ -5358,7 +5359,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
INIT_ANCHOR(args);
argc = setup_args(iseq, args, node->nd_args, &flag);
- flag |= COMPILE_RECV(recv, "recv", node);
+ flag |= (asgnflag = COMPILE_RECV(recv, "recv", node));
debugp_param("argc", argc);
debugp_param("nd_mid", ID2SYM(node->nd_mid));
@@ -5372,7 +5373,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
ADD_INSN1(ret, line, topn, INT2FIX(1));
if (flag & VM_CALL_ARGS_SPLAT) {
ADD_INSN1(ret, line, putobject, INT2FIX(-1));
- ADD_SEND(ret, line, ID2SYM(idAREF), INT2FIX(1));
+ ADD_SEND_R(ret, line, ID2SYM(idAREF), INT2FIX(1), Qfalse, INT2FIX(asgnflag));
}
ADD_INSN1(ret, line, setn, FIXNUM_INC(argc, 3));
ADD_INSN (ret, line, pop);
@@ -5380,7 +5381,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
else if (flag & VM_CALL_ARGS_SPLAT) {
ADD_INSN(ret, line, dup);
ADD_INSN1(ret, line, putobject, INT2FIX(-1));
- ADD_SEND(ret, line, ID2SYM(idAREF), INT2FIX(1));
+ ADD_SEND_R(ret, line, ID2SYM(idAREF), INT2FIX(1), Qfalse, INT2FIX(asgnflag));
ADD_INSN1(ret, line, setn, FIXNUM_INC(argc, 2));
ADD_INSN (ret, line, pop);
}
diff --git a/test/ruby/test_assignment.rb b/test/ruby/test_assignment.rb
index c6f1cd1bc7..9c0fd48725 100644
--- a/test/ruby/test_assignment.rb
+++ b/test/ruby/test_assignment.rb
@@ -106,9 +106,9 @@ class TestAssignment < Test::Unit::TestCase
o = Object.new
class << o
+ private
def foo; 42; end
def [](i); 42; end
- private
def foo=(a); 42; end
def []=(i, a); 42; end
end