Actions
Bug #10060
closedprivate attr_accessor and NoMethodError
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
Backport:
Description
class Bug
def initialize
self.n = 1 # ok
end
def t1
self.n = n + 1 # ok
self.n += 1 # in `t1': private method `n' called for #<Bug:0x000000019ae1a0 @n=2> (NoMethodError)
end
def t2
n # ok
self.n # in `t2': private method `n' called for #<Bug:0x0000000218a360 @n=1> (NoMethodError)
end
private
attr_accessor :n
end
Updated by avit (Andrew Vit) over 10 years ago
Not a bug, there is no such thing as a private accessor
Updated by nobu (Nobuyoshi Nakada) over 10 years ago
- Related to Bug #9907: Abbreviated method assignment with private attr_writer/attr_reader does not work. added
Updated by nobu (Nobuyoshi Nakada) over 10 years ago
- Description updated (diff)
diff --git i/compile.c w/compile.c
index 637e112..556efc2 100644
--- i/compile.c
+++ w/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);
Updated by nobu (Nobuyoshi Nakada) over 10 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
Applied in changeset r46873.
compile.c: private reader in op_assign
- compile.c (iseq_compile_each): allow to access private attribute
reader in op_assign. [ruby-core:63817] [Bug #10060]
Updated by nobu (Nobuyoshi Nakada) over 7 years ago
- Related to Bug #11096: 'private' access control bypassed when ||= is used added
Actions
Like0
Like0Like0Like0Like0Like0