ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:62949] [ruby-trunk - Bug #9907] [Open] Abbreviated method assignment with private attr_writer/attr_reader does not work.
       [not found] <redmine.issue-9907.20140605155013@ruby-lang.org>
@ 2014-06-05 15:50 ` JoergWMittag+Ruby-Lang
  2014-06-06  8:06 ` [ruby-core:62958] [ruby-trunk - Bug #9907] " nobu
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: JoergWMittag+Ruby-Lang @ 2014-06-05 15:50 UTC (permalink / raw
  To: ruby-core

Issue #9907 has been reported by Jörg W Mittag.

----------------------------------------
Bug #9907: Abbreviated method assignment with private attr_writer/attr_reader does not work.
https://bugs.ruby-lang.org/issues/9907

* Author: Jörg W Mittag
* Status: Open
* Priority: Normal
* Assignee: 
* Category: core
* Target version: current: 2.2.0
* ruby -v: ruby 2.2.0dev (2014-06-05 trunk 46357) [x86_64-darwin13]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
This looks like a hole in the specification:

~~~
private def foo=(*) end
public  def foo; 0  end

self.foo =  42

self.foo += 42
# private method `foo=' called for main:Object (NoMethodError)

private :foo

self.foo += 42
# private method `foo' called for main:Object (NoMethodError)
~~~

There is an exception for `private` writers in the rule for private message sends, but apparently that exception needs to broadened so that it also works in the case of abbreviated assignments. I'm not entirely sure what this rule would be, but I don't think it would break backwards compatibility, since all situations that would work differently with the changed rule would currently raise a `NoMethodError` anyway.

The rule should be something like:

> * `private` methods can only be called without an explicit receiver.
> * An exception is made for method assignments, where the literal receiver `self` is also allowed in the assignee method expression.
> * This also applies to compound assignments: `self.foo ω= bar` shall *always* succeed if either or both of `foo` and `foo=` are `private`.



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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:62958] [ruby-trunk - Bug #9907] Abbreviated method assignment with private attr_writer/attr_reader does not work.
       [not found] <redmine.issue-9907.20140605155013@ruby-lang.org>
  2014-06-05 15:50 ` [ruby-core:62949] [ruby-trunk - Bug #9907] [Open] Abbreviated method assignment with private attr_writer/attr_reader does not work JoergWMittag+Ruby-Lang
@ 2014-06-06  8:06 ` nobu
  2014-06-06  8:06 ` [ruby-core:62959] " nobu
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: nobu @ 2014-06-06  8:06 UTC (permalink / raw
  To: ruby-core

Issue #9907 has been updated by Nobuyoshi Nakada.

Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: REQUIRED, 2.1: REQUIRED

----------------------------------------
Bug #9907: Abbreviated method assignment with private attr_writer/attr_reader does not work.
https://bugs.ruby-lang.org/issues/9907#change-47059

* Author: Jörg W Mittag
* Status: Open
* Priority: Normal
* Assignee: 
* Category: core
* Target version: current: 2.2.0
* ruby -v: ruby 2.2.0dev (2014-06-05 trunk 46357) [x86_64-darwin13]
* Backport: 2.0.0: REQUIRED, 2.1: REQUIRED
----------------------------------------
This looks like a hole in the specification:

~~~
private def foo=(*) end
public  def foo; 0  end

self.foo =  42

self.foo += 42
# private method `foo=' called for main:Object (NoMethodError)

private :foo

self.foo += 42
# private method `foo' called for main:Object (NoMethodError)
~~~

There is an exception for `private` writers in the rule for private message sends, but apparently that exception needs to broadened so that it also works in the case of abbreviated assignments. I'm not entirely sure what this rule would be, but I don't think it would break backwards compatibility, since all situations that would work differently with the changed rule would currently raise a `NoMethodError` anyway.

The rule should be something like:

> * `private` methods can only be called without an explicit receiver.
> * An exception is made for method assignments, where the literal receiver `self` is also allowed in the assignee method expression.
> * This also applies to compound assignments: `self.foo ω= bar` shall *always* succeed if either or both of `foo` and `foo=` are `private`.



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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:62959] [ruby-trunk - Bug #9907] Abbreviated method assignment with private attr_writer/attr_reader does not work.
       [not found] <redmine.issue-9907.20140605155013@ruby-lang.org>
  2014-06-05 15:50 ` [ruby-core:62949] [ruby-trunk - Bug #9907] [Open] Abbreviated method assignment with private attr_writer/attr_reader does not work JoergWMittag+Ruby-Lang
  2014-06-06  8:06 ` [ruby-core:62958] [ruby-trunk - Bug #9907] " nobu
@ 2014-06-06  8:06 ` nobu
  2014-06-06  8:07 ` [ruby-core:62960] [ruby-trunk - Bug #9907] [Closed] " nobu
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: nobu @ 2014-06-06  8:06 UTC (permalink / raw
  To: ruby-core

Issue #9907 has been updated by Nobuyoshi Nakada.

Description updated

----------------------------------------
Bug #9907: Abbreviated method assignment with private attr_writer/attr_reader does not work.
https://bugs.ruby-lang.org/issues/9907#change-47060

* Author: Jörg W Mittag
* Status: Open
* Priority: Normal
* Assignee: 
* Category: core
* Target version: current: 2.2.0
* ruby -v: ruby 2.2.0dev (2014-06-05 trunk 46357) [x86_64-darwin13]
* Backport: 2.0.0: REQUIRED, 2.1: REQUIRED
----------------------------------------
This looks like a hole in the specification:

~~~ruby
private def foo=(*) end
public  def foo; 0  end

self.foo =  42

self.foo += 42
# private method `foo=' called for main:Object (NoMethodError)

private :foo

self.foo += 42
# private method `foo' called for main:Object (NoMethodError)
~~~

There is an exception for `private` writers in the rule for private message sends, but apparently that exception needs to broadened so that it also works in the case of abbreviated assignments. I'm not entirely sure what this rule would be, but I don't think it would break backwards compatibility, since all situations that would work differently with the changed rule would currently raise a `NoMethodError` anyway.

The rule should be something like:

> * `private` methods can only be called without an explicit receiver.
> * An exception is made for method assignments, where the literal receiver `self` is also allowed in the assignee method expression.
> * This also applies to compound assignments: `self.foo ω= bar` shall *always* succeed if either or both of `foo` and `foo=` are `private`.



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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:62960] [ruby-trunk - Bug #9907] [Closed] Abbreviated method assignment with private attr_writer/attr_reader does not work.
       [not found] <redmine.issue-9907.20140605155013@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2014-06-06  8:06 ` [ruby-core:62959] " nobu
@ 2014-06-06  8:07 ` nobu
  2014-07-18 17:17 ` [ruby-core:63832] [ruby-trunk - Bug #9907] " nobu
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: nobu @ 2014-06-06  8:07 UTC (permalink / raw
  To: ruby-core

Issue #9907 has been updated by Nobuyoshi Nakada.

Status changed from Open to Closed
% Done changed from 0 to 100

Applied in changeset r46365.

----------
compile.c, parse.y: private op assign

* compile.c (iseq_compile_each), parse.y (new_attr_op_assign_gen):
  allow op assign to a private attribute.
  [ruby-core:62949] [Bug #9907]

----------------------------------------
Bug #9907: Abbreviated method assignment with private attr_writer/attr_reader does not work.
https://bugs.ruby-lang.org/issues/9907#change-47061

* Author: Jörg W Mittag
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: core
* Target version: current: 2.2.0
* ruby -v: ruby 2.2.0dev (2014-06-05 trunk 46357) [x86_64-darwin13]
* Backport: 2.0.0: REQUIRED, 2.1: REQUIRED
----------------------------------------
This looks like a hole in the specification:

~~~ruby
private def foo=(*) end
public  def foo; 0  end

self.foo =  42

self.foo += 42
# private method `foo=' called for main:Object (NoMethodError)

private :foo

self.foo += 42
# private method `foo' called for main:Object (NoMethodError)
~~~

There is an exception for `private` writers in the rule for private message sends, but apparently that exception needs to broadened so that it also works in the case of abbreviated assignments. I'm not entirely sure what this rule would be, but I don't think it would break backwards compatibility, since all situations that would work differently with the changed rule would currently raise a `NoMethodError` anyway.

The rule should be something like:

> * `private` methods can only be called without an explicit receiver.
> * An exception is made for method assignments, where the literal receiver `self` is also allowed in the assignee method expression.
> * This also applies to compound assignments: `self.foo ω= bar` shall *always* succeed if either or both of `foo` and `foo=` are `private`.



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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:63832] [ruby-trunk - Bug #9907] Abbreviated method assignment with private attr_writer/attr_reader does not work.
       [not found] <redmine.issue-9907.20140605155013@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2014-06-06  8:07 ` [ruby-core:62960] [ruby-trunk - Bug #9907] [Closed] " nobu
@ 2014-07-18 17:17 ` nobu
  2014-09-14 14:47 ` [ruby-core:65033] " nagachika00
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: nobu @ 2014-07-18 17:17 UTC (permalink / raw
  To: ruby-core

Issue #9907 has been updated by Nobuyoshi Nakada.

Related to Bug #10060: private attr_accessor and NoMethodError added

----------------------------------------
Bug #9907: Abbreviated method assignment with private attr_writer/attr_reader does not work.
https://bugs.ruby-lang.org/issues/9907#change-47869

* Author: Jörg W Mittag
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: core
* Target version: current: 2.2.0
* ruby -v: ruby 2.2.0dev (2014-06-05 trunk 46357) [x86_64-darwin13]
* Backport: 2.0.0: REQUIRED, 2.1: REQUIRED
----------------------------------------
This looks like a hole in the specification:

~~~ruby
private def foo=(*) end
public  def foo; 0  end

self.foo =  42

self.foo += 42
# private method `foo=' called for main:Object (NoMethodError)

private :foo

self.foo += 42
# private method `foo' called for main:Object (NoMethodError)
~~~

There is an exception for `private` writers in the rule for private message sends, but apparently that exception needs to broadened so that it also works in the case of abbreviated assignments. I'm not entirely sure what this rule would be, but I don't think it would break backwards compatibility, since all situations that would work differently with the changed rule would currently raise a `NoMethodError` anyway.

The rule should be something like:

> * `private` methods can only be called without an explicit receiver.
> * An exception is made for method assignments, where the literal receiver `self` is also allowed in the assignee method expression.
> * This also applies to compound assignments: `self.foo ω= bar` shall *always* succeed if either or both of `foo` and `foo=` are `private`.



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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:65033] [ruby-trunk - Bug #9907] Abbreviated method assignment with private attr_writer/attr_reader does not work.
       [not found] <redmine.issue-9907.20140605155013@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2014-07-18 17:17 ` [ruby-core:63832] [ruby-trunk - Bug #9907] " nobu
@ 2014-09-14 14:47 ` nagachika00
  2014-11-06 16:41 ` [ruby-core:66121] " headius
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: nagachika00 @ 2014-09-14 14:47 UTC (permalink / raw
  To: ruby-core

Issue #9907 has been updated by Tomoyuki Chikanaga.

Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED to 2.0.0: REQUIRED, 2.1: DONTNEED

This seems a spec change for me. Any comments?

----------------------------------------
Bug #9907: Abbreviated method assignment with private attr_writer/attr_reader does not work.
https://bugs.ruby-lang.org/issues/9907#change-48900

* Author: Jörg W Mittag
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: core
* Target version: current: 2.2.0
* ruby -v: ruby 2.2.0dev (2014-06-05 trunk 46357) [x86_64-darwin13]
* Backport: 2.0.0: REQUIRED, 2.1: DONTNEED
----------------------------------------
This looks like a hole in the specification:

~~~ruby
private def foo=(*) end
public  def foo; 0  end

self.foo =  42

self.foo += 42
# private method `foo=' called for main:Object (NoMethodError)

private :foo

self.foo += 42
# private method `foo' called for main:Object (NoMethodError)
~~~

There is an exception for `private` writers in the rule for private message sends, but apparently that exception needs to broadened so that it also works in the case of abbreviated assignments. I'm not entirely sure what this rule would be, but I don't think it would break backwards compatibility, since all situations that would work differently with the changed rule would currently raise a `NoMethodError` anyway.

The rule should be something like:

> * `private` methods can only be called without an explicit receiver.
> * An exception is made for method assignments, where the literal receiver `self` is also allowed in the assignee method expression.
> * This also applies to compound assignments: `self.foo ω= bar` shall *always* succeed if either or both of `foo` and `foo=` are `private`.



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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:66121] [ruby-trunk - Bug #9907] Abbreviated method assignment with private attr_writer/attr_reader does not work.
       [not found] <redmine.issue-9907.20140605155013@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2014-09-14 14:47 ` [ruby-core:65033] " nagachika00
@ 2014-11-06 16:41 ` headius
  2014-11-07  1:22 ` [ruby-core:66123] " nobu
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: headius @ 2014-11-06 16:41 UTC (permalink / raw
  To: ruby-core

Issue #9907 has been updated by Charles Nutter.


I'm confused about how private dispatch against self should behave. I expected that *at least* all self.x calls would be considered private dispatch, but that's not the case.

For this code:

private
def foo; @a; end
def foo=(a); @a = a; end

puts begin; foo; rescue; 'foo failed'; else; 'foo worked'; end
puts begin; self.foo; rescue; 'self.foo failed'; else; 'self.foo worked'; end
puts begin; self.foo = 1; rescue; 'self.foo = 1 failed'; else; 'self.foo = 1 worked'; end
puts begin; self.foo += 1; rescue; 'self.foo += 1 failed'; else; 'self.foo += 1 worked'; end
puts begin; o = self; o.foo; rescue; 'o = self; o.foo failed'; else; 'o = self; o.foo worked'; end
puts begin; o = self; o.foo = 1; rescue; 'o = self; o.foo = 1 failed'; else; 'o = self; o.foo = 1 worked'; end

I have the following behavior with 2.2.0-preview1:

foo worked
self.foo failed
self.foo = 1 worked
self.foo += 1 worked
o = self; o.foo failed
o = self; o.foo = 1 failed

On 2.1, the self.foo += 1 case failed, which is the purpose of this bug.

However, I don't see why that case should pass and self.foo should fail. self.foo += must do an implicit self.foo call, meaning the "self" exception for private dispatch propagates through. It makes no sense that directly calling self.foo would produce an error and implicitly calling self.foo would not.

I would also argue that the "o" cases should pass as well, but I'm more concerned about the inconsistent spec change in this bug.

----------------------------------------
Bug #9907: Abbreviated method assignment with private attr_writer/attr_reader does not work.
https://bugs.ruby-lang.org/issues/9907#change-49831

* Author: Jörg W Mittag
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: core
* Target version: current: 2.2.0
* ruby -v: ruby 2.2.0dev (2014-06-05 trunk 46357) [x86_64-darwin13]
* Backport: 2.0.0: REQUIRED, 2.1: DONTNEED
----------------------------------------
This looks like a hole in the specification:

~~~ruby
private def foo=(*) end
public  def foo; 0  end

self.foo =  42

self.foo += 42
# private method `foo=' called for main:Object (NoMethodError)

private :foo

self.foo += 42
# private method `foo' called for main:Object (NoMethodError)
~~~

There is an exception for `private` writers in the rule for private message sends, but apparently that exception needs to broadened so that it also works in the case of abbreviated assignments. I'm not entirely sure what this rule would be, but I don't think it would break backwards compatibility, since all situations that would work differently with the changed rule would currently raise a `NoMethodError` anyway.

The rule should be something like:

> * `private` methods can only be called without an explicit receiver.
> * An exception is made for method assignments, where the literal receiver `self` is also allowed in the assignee method expression.
> * This also applies to compound assignments: `self.foo ω= bar` shall *always* succeed if either or both of `foo` and `foo=` are `private`.



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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:66123] [ruby-trunk - Bug #9907] Abbreviated method assignment with private attr_writer/attr_reader does not work.
       [not found] <redmine.issue-9907.20140605155013@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2014-11-06 16:41 ` [ruby-core:66121] " headius
@ 2014-11-07  1:22 ` nobu
  2014-11-07 18:13 ` [ruby-core:66138] " headius
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: nobu @ 2014-11-07  1:22 UTC (permalink / raw
  To: ruby-core

Issue #9907 has been updated by Nobuyoshi Nakada.


I think, `+=` is a kind of assignment, so it should allow even private attributes as a whole.

----------------------------------------
Bug #9907: Abbreviated method assignment with private attr_writer/attr_reader does not work.
https://bugs.ruby-lang.org/issues/9907#change-49832

* Author: Jörg W Mittag
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: core
* Target version: current: 2.2.0
* ruby -v: ruby 2.2.0dev (2014-06-05 trunk 46357) [x86_64-darwin13]
* Backport: 2.0.0: REQUIRED, 2.1: DONTNEED
----------------------------------------
This looks like a hole in the specification:

~~~ruby
private def foo=(*) end
public  def foo; 0  end

self.foo =  42

self.foo += 42
# private method `foo=' called for main:Object (NoMethodError)

private :foo

self.foo += 42
# private method `foo' called for main:Object (NoMethodError)
~~~

There is an exception for `private` writers in the rule for private message sends, but apparently that exception needs to broadened so that it also works in the case of abbreviated assignments. I'm not entirely sure what this rule would be, but I don't think it would break backwards compatibility, since all situations that would work differently with the changed rule would currently raise a `NoMethodError` anyway.

The rule should be something like:

> * `private` methods can only be called without an explicit receiver.
> * An exception is made for method assignments, where the literal receiver `self` is also allowed in the assignee method expression.
> * This also applies to compound assignments: `self.foo ω= bar` shall *always* succeed if either or both of `foo` and `foo=` are `private`.



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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:66138] [ruby-trunk - Bug #9907] Abbreviated method assignment with private attr_writer/attr_reader does not work.
       [not found] <redmine.issue-9907.20140605155013@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2014-11-07  1:22 ` [ruby-core:66123] " nobu
@ 2014-11-07 18:13 ` headius
  2014-11-08 21:31 ` [ruby-core:66149] " eregontp
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: headius @ 2014-11-07 18:13 UTC (permalink / raw
  To: ruby-core

Issue #9907 has been updated by Charles Nutter.


The following two pieces of code should both work, since they both do the same thing. VM-level exceptions *hurt* understandability, and it should come as a surprise to any Rubyist that self.foo+= can skip visibility checks but self.foo can't.

self.foo += 1 # ok

AND

self.foo = self.foo + 1 # visibility error

The first line essentially expands to the second line. The first line works, the second line doesn't. That makes no sense to me. Also, what if I had "self.foo += 1" (working fine after this bug) and later wanted to expand the logic to add some additional operations. It would break, and I wouldn't understand why.

self.foo = self.foo * 5 + 1 # visibility error

I think consistency wins here and self.foo should be able to skip visibility checks too.

----------------------------------------
Bug #9907: Abbreviated method assignment with private attr_writer/attr_reader does not work.
https://bugs.ruby-lang.org/issues/9907#change-49844

* Author: Jörg W Mittag
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: core
* Target version: current: 2.2.0
* ruby -v: ruby 2.2.0dev (2014-06-05 trunk 46357) [x86_64-darwin13]
* Backport: 2.0.0: REQUIRED, 2.1: DONTNEED
----------------------------------------
This looks like a hole in the specification:

~~~ruby
private def foo=(*) end
public  def foo; 0  end

self.foo =  42

self.foo += 42
# private method `foo=' called for main:Object (NoMethodError)

private :foo

self.foo += 42
# private method `foo' called for main:Object (NoMethodError)
~~~

There is an exception for `private` writers in the rule for private message sends, but apparently that exception needs to broadened so that it also works in the case of abbreviated assignments. I'm not entirely sure what this rule would be, but I don't think it would break backwards compatibility, since all situations that would work differently with the changed rule would currently raise a `NoMethodError` anyway.

The rule should be something like:

> * `private` methods can only be called without an explicit receiver.
> * An exception is made for method assignments, where the literal receiver `self` is also allowed in the assignee method expression.
> * This also applies to compound assignments: `self.foo ω= bar` shall *always* succeed if either or both of `foo` and `foo=` are `private`.



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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:66149] [ruby-trunk - Bug #9907] Abbreviated method assignment with private attr_writer/attr_reader does not work.
       [not found] <redmine.issue-9907.20140605155013@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2014-11-07 18:13 ` [ruby-core:66138] " headius
@ 2014-11-08 21:31 ` eregontp
  2017-04-27 12:19 ` [ruby-core:80907] [Ruby trunk Bug#9907] " siimliiser
  2017-04-27 15:12 ` [ruby-core:80910] " nobu
  11 siblings, 0 replies; 12+ messages in thread
From: eregontp @ 2014-11-08 21:31 UTC (permalink / raw
  To: ruby-core

Issue #9907 has been updated by Benoit Daloze.


Until now, the ability to call private methods has always been a property verifiable at parse time
(no receiver or "receiver is self and methods ends with =").

I think it is good to remain that way so it is really easy to know whether you may call private method, as a Ruby user.
So I think the "o" cases above should not be able to call private methods.

On the other hand, the current semantics seem less clear and more complex than they could be.
I agree with Charles, the "no explicit receiver or receiver is literally `self`" rule is simpler, more consistent and avoid problems with special cases such as assignments.

Having a hidden implicit visibility such as in the committed change seems harder for everyone to understand and may only solve a part of the special cases.

----------------------------------------
Bug #9907: Abbreviated method assignment with private attr_writer/attr_reader does not work.
https://bugs.ruby-lang.org/issues/9907#change-49852

* Author: Jörg W Mittag
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: core
* Target version: current: 2.2.0
* ruby -v: ruby 2.2.0dev (2014-06-05 trunk 46357) [x86_64-darwin13]
* Backport: 2.0.0: REQUIRED, 2.1: DONTNEED
----------------------------------------
This looks like a hole in the specification:

~~~ruby
private def foo=(*) end
public  def foo; 0  end

self.foo =  42

self.foo += 42
# private method `foo=' called for main:Object (NoMethodError)

private :foo

self.foo += 42
# private method `foo' called for main:Object (NoMethodError)
~~~

There is an exception for `private` writers in the rule for private message sends, but apparently that exception needs to broadened so that it also works in the case of abbreviated assignments. I'm not entirely sure what this rule would be, but I don't think it would break backwards compatibility, since all situations that would work differently with the changed rule would currently raise a `NoMethodError` anyway.

The rule should be something like:

> * `private` methods can only be called without an explicit receiver.
> * An exception is made for method assignments, where the literal receiver `self` is also allowed in the assignee method expression.
> * This also applies to compound assignments: `self.foo ω= bar` shall *always* succeed if either or both of `foo` and `foo=` are `private`.



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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:80907] [Ruby trunk Bug#9907] Abbreviated method assignment with private attr_writer/attr_reader does not work.
       [not found] <redmine.issue-9907.20140605155013@ruby-lang.org>
                   ` (9 preceding siblings ...)
  2014-11-08 21:31 ` [ruby-core:66149] " eregontp
@ 2017-04-27 12:19 ` siimliiser
  2017-04-27 15:12 ` [ruby-core:80910] " nobu
  11 siblings, 0 replies; 12+ messages in thread
From: siimliiser @ 2017-04-27 12:19 UTC (permalink / raw
  To: ruby-core

Issue #9907 has been updated by siimliiser (Siim Liiser).


This issue seems to have resurfaced. The issue is fixed in 2.2, but broken in both 2.3 and 2.4.

----------------------------------------
Bug #9907: Abbreviated method assignment with private attr_writer/attr_reader does not work.
https://bugs.ruby-lang.org/issues/9907#change-64512

* Author: jwmittag (Jörg W Mittag)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 2.2.0
* ruby -v: ruby 2.2.0dev (2014-06-05 trunk 46357) [x86_64-darwin13]
* Backport: 2.0.0: REQUIRED, 2.1: DONTNEED
----------------------------------------
This looks like a hole in the specification:

~~~ruby
private def foo=(*) end
public  def foo; 0  end

self.foo =  42

self.foo += 42
# private method `foo=' called for main:Object (NoMethodError)

private :foo

self.foo += 42
# private method `foo' called for main:Object (NoMethodError)
~~~

There is an exception for `private` writers in the rule for private message sends, but apparently that exception needs to broadened so that it also works in the case of abbreviated assignments. I'm not entirely sure what this rule would be, but I don't think it would break backwards compatibility, since all situations that would work differently with the changed rule would currently raise a `NoMethodError` anyway.

The rule should be something like:

> * `private` methods can only be called without an explicit receiver.
> * An exception is made for method assignments, where the literal receiver `self` is also allowed in the assignee method expression.
> * This also applies to compound assignments: `self.foo ω= bar` shall *always* succeed if either or both of `foo` and `foo=` are `private`.



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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:80910] [Ruby trunk Bug#9907] Abbreviated method assignment with private attr_writer/attr_reader does not work.
       [not found] <redmine.issue-9907.20140605155013@ruby-lang.org>
                   ` (10 preceding siblings ...)
  2017-04-27 12:19 ` [ruby-core:80907] [Ruby trunk Bug#9907] " siimliiser
@ 2017-04-27 15:12 ` nobu
  11 siblings, 0 replies; 12+ messages in thread
From: nobu @ 2017-04-27 15:12 UTC (permalink / raw
  To: ruby-core

Issue #9907 has been updated by nobu (Nobuyoshi Nakada).


Intentional fix.

----------------------------------------
Bug #9907: Abbreviated method assignment with private attr_writer/attr_reader does not work.
https://bugs.ruby-lang.org/issues/9907#change-64521

* Author: jwmittag (Jörg W Mittag)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 2.2.0
* ruby -v: ruby 2.2.0dev (2014-06-05 trunk 46357) [x86_64-darwin13]
* Backport: 2.0.0: REQUIRED, 2.1: DONTNEED
----------------------------------------
This looks like a hole in the specification:

~~~ruby
private def foo=(*) end
public  def foo; 0  end

self.foo =  42

self.foo += 42
# private method `foo=' called for main:Object (NoMethodError)

private :foo

self.foo += 42
# private method `foo' called for main:Object (NoMethodError)
~~~

There is an exception for `private` writers in the rule for private message sends, but apparently that exception needs to broadened so that it also works in the case of abbreviated assignments. I'm not entirely sure what this rule would be, but I don't think it would break backwards compatibility, since all situations that would work differently with the changed rule would currently raise a `NoMethodError` anyway.

The rule should be something like:

> * `private` methods can only be called without an explicit receiver.
> * An exception is made for method assignments, where the literal receiver `self` is also allowed in the assignee method expression.
> * This also applies to compound assignments: `self.foo ω= bar` shall *always* succeed if either or both of `foo` and `foo=` are `private`.



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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-04-27 14:30 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-9907.20140605155013@ruby-lang.org>
2014-06-05 15:50 ` [ruby-core:62949] [ruby-trunk - Bug #9907] [Open] Abbreviated method assignment with private attr_writer/attr_reader does not work JoergWMittag+Ruby-Lang
2014-06-06  8:06 ` [ruby-core:62958] [ruby-trunk - Bug #9907] " nobu
2014-06-06  8:06 ` [ruby-core:62959] " nobu
2014-06-06  8:07 ` [ruby-core:62960] [ruby-trunk - Bug #9907] [Closed] " nobu
2014-07-18 17:17 ` [ruby-core:63832] [ruby-trunk - Bug #9907] " nobu
2014-09-14 14:47 ` [ruby-core:65033] " nagachika00
2014-11-06 16:41 ` [ruby-core:66121] " headius
2014-11-07  1:22 ` [ruby-core:66123] " nobu
2014-11-07 18:13 ` [ruby-core:66138] " headius
2014-11-08 21:31 ` [ruby-core:66149] " eregontp
2017-04-27 12:19 ` [ruby-core:80907] [Ruby trunk Bug#9907] " siimliiser
2017-04-27 15:12 ` [ruby-core:80910] " nobu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).