Issue #4537 has been updated by jeremyevans0 (Jeremy Evans).

File attr-visibility-4537.patch added

Attached is a patch that makes attr* methods handle visibility the same as `define_method`, using the approach nobu developed for #9005.  I think this behavior makes the most sense.  Always defining attr* methods as public (approach (2)) breaks backwards compatibility in more cases, and could lead to security issues in cases where public methods are treated differently than private methods in regards to how user input is handled.

----------------------------------------
Bug #4537: Incorrectly creating private method via attr_accessor
https://bugs.ruby-lang.org/issues/4537#change-80317

* Author: ryanlecompte (Ryan LeCompte)
* Status: Assigned
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Target version: 
* ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
```
# The following fails with a failure to call "x=" private method
String.send(:attr_accessor, :x)
s = ""
s.x = 100

# The following works:
class String
  self.send(:attr_accessor, :x)
end
s = ""
s.x = 100
```


---Files--------------------------------
attr-visibility-4537.patch (2.75 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>