From: "tatethurston (Tate Thurston) via ruby-core" Date: 2024-07-20T00:45:36+00:00 Subject: [ruby-core:118642] [Ruby master Bug#20643] Ruby 3.2 behavior change for protected and private methods when yield self Issue #20643 has been reported by tatethurston (Tate Thurston). ---------------------------------------- Bug #20643: Ruby 3.2 behavior change for protected and private methods when yield self https://bugs.ruby-lang.org/issues/20643 * Author: tatethurston (Tate Thurston) * Status: Open * 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 # (NoMethodError) from (irb):14:in `
' from /Users/tatthurs/.asdf/installs/ruby/3.2.4/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11:in `' 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 `
' irb(main):015:0> ``` Is this change expected? I could not find a note in the changelog. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/