From: nobu@... Date: 2014-07-18T17:18:49+00:00 Subject: [ruby-core:63834] [ruby-trunk - Bug #10060] private attr_accessor and NoMethodError Issue #10060 has been updated by Nobuyoshi Nakada. 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); ~~~ ---------------------------------------- Bug #10060: private attr_accessor and NoMethodError https://bugs.ruby-lang.org/issues/10060#change-47870 * Author: John Doe * Status: Open * Priority: Normal * Assignee: * Category: * Target version: * ruby -v: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- ~~~ruby 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 # (NoMethodError) end def t2 n # ok self.n # in `t2': private method `n' called for # (NoMethodError) end private attr_accessor :n end ~~~ -- https://bugs.ruby-lang.org/