
Issue #20643 has been updated by jeremyevans0 (Jeremy Evans). Status changed from Open to Closed It is expected, see #18826. As it was a bug fix and not a new feature, it wasn't mentioned in NEWS, though I can see it causing problems for code that relied on the previous behavior. ---------------------------------------- Bug #20643: Ruby 3.2 behavior change for protected and private methods when yield self https://bugs.ruby-lang.org/issues/20643#change-109170 * Author: tatethurston (Tate Thurston) * Status: Closed * ruby -v: ruby 3.2.4 (2024-04-23 revision af471c0e01) [arm64-darwin23] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- I noticed the following behavior change when updating my application from Ruby 3.1 to Ruby 3.2. Using the following code: ``` ruby class Foo def try yield self end private def bar puts "private method bar called" end end Foo.new.try(&:bar) ``` Under 3.1 (ruby 3.1.6p260 (2024-05-29 revision a777087be6) [arm64-darwin23]) ``` private method bar called => nil ``` Under Ruby 3.2 (ruby 3.2.4 (2024-04-23 revision af471c0e01) [arm64-darwin23]) ``` (irb):4:in `try': private method `bar' called for #<Foo:0x000000010770a578> (NoMethodError) from (irb):14:in `<main>' from /Users/tatthurs/.asdf/installs/ruby/3.2.4/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11:in `<top (required)>' from /Users/tatthurs/.asdf/installs/ruby/3.2.4/bin/irb:25:in `load' from /Users/tatthurs/.asdf/installs/ruby/3.2.4/bin/irb:25:in `<main>' irb(main):015:0> ``` Is this change expected? I could not find a note in the changelog. -- https://bugs.ruby-lang.org/