Project

General

Profile

Actions

Bug #15255

closed

Change in protected handling 2.3 -> 2.4,2.5

Added by viraptor (Stan Pitucha) over 5 years ago. Updated over 4 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:89561]

Description

It looks like when moving to 2.4 and higher, the access to protected method has changed. In the following case:

class Foo
  def bar(objects)
    objects.map(&:baz)
  end

  protected

  def baz
    self.inspect
  end
end

a = Foo.new; b = Foo.new

a.bar([b])

The protected method '...' called will be raised. I haven't seen any explicit mention of this in the release notes.
It can be rewritten to successfully run as:

objects.map { |x| x.baz }

But it was an unexpected change. (so potentially a bug?)

Actions

Also available in: Atom PDF

Like0
Like0