From: "mame (Yusuke Endoh)" Date: 2022-05-18T01:27:12+00:00 Subject: [ruby-core:108605] [Ruby master Bug#18751] Regression on master for Method#== when comparing public with private method Issue #18751 has been updated by mame (Yusuke Endoh). jeremyevans0 (Jeremy Evans) wrote in #note-10: > you would have to make it so the `rb_method_entry_t*` points to the ZSUPER method. Yes. I meant it by "we determined to allow a Method object for ZSUPER method entry". > Lacking a detailed understanding of why the code is the way it is, I made the assumption that there is a reason the `rb_method_entry_t*` points to the original method, I think the original author (matz? nobu? Or ko1? I don't know) wanted to hide ZSUPER method entry from users because it is an implementation detail. However, #18729 showed that the hiding was incomplete. At the previous dev meeting, we discussed whether the hiding is really needed, and agreed to stop hiding it (https://bugs.ruby-lang.org/issues/18729#note-6). > and I took the conservative approach of just adding visibility information without changing other internals. You are very thoughtful and wonderful! Thank you always. ---------------------------------------- Bug #18751: Regression on master for Method#== when comparing public with private method https://bugs.ruby-lang.org/issues/18751#change-97642 * Author: Eregon (Benoit Daloze) * Status: Open * Priority: Normal * ruby -v: ruby 3.2.0dev (2022-04-23T02:59:20Z master e142bea799) [x86_64-linux] * Backport: 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED ---------------------------------------- This script repros: ```ruby class C class << self alias_method :n, :new private :new end end p C.method(:n) == C.method(:new) # => true puts p C.method(:n) == Class.method(:new) # => false p C.method(:n) == Class.method(:new).unbind.bind(C) # => true puts p C.method(:new) == Class.method(:new) # => false p C.method(:new) == Class.method(:new).unbind.bind(C) # => true, BUT false on master p C.method(:new) == Class.instance_method(:new).bind(C) # => true, BUT false on master p [C.method(:new), Class.instance_method(:new).bind(C)] # => [#(Class)#new(*)>, #(Class)#new(*)>] ``` So this prints the expected results on 2.7.5, 3.0.3, 3.1.1 but not on master, which seems a regression. Notably this breaks the pattern discussed in https://bugs.ruby-lang.org/issues/18729#note-5, and it means there is no way to find out if two methods share the same "definition/logic/def", which is a big limitation. -- https://bugs.ruby-lang.org/ Unsubscribe: