Actions
Bug #16947
closedprivate method unexpected behavior
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
Description
private method called explicitly through self should return an error, but in version 2.7.1 an error does not occur and the method is executed
Files
Updated by nobu (Nobuyoshi Nakada) over 4 years ago
- Related to Feature #11297: Allow private method of self to be called added
Updated by kapitan_morgan (Yaromir Bartosh) over 4 years ago
class Person
def speak
puts "Hey, Tj!"
end
def whisper_louder
whisper
end
def whisper_self
self.whisper
end
private
def whisper
puts "His name's not really 'Tj'."
end
end
p = Person.new
p.speak
p.whisper_louder
# should cause an error
# but in version 2.7.1 no error occurs
p.whisper_self
Updated by nobu (Nobuyoshi Nakada) over 4 years ago
- Related to Feature #16123: Allow calling a private method with `self.` added
Updated by nobu (Nobuyoshi Nakada) over 4 years ago
- Status changed from Open to Closed
It is allowed since 2.7.0.
Actions
Like0
Like0Like0Like0Like0Like0