Issue #16947 has been updated by kapitan_morgan (Yaromir Bartosh).


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

----------------------------------------
Bug #16947: private method unexpected behavior
https://bugs.ruby-lang.org/issues/16947#change-86058

* Author: kapitan_morgan (Yaromir Bartosh)
* Status: Open
* Priority: Normal
* ruby -v: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
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--------------------------------
private_method.rb (331 Bytes)


-- 
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>