From: "Eregon (Benoit Daloze)" <noreply@ruby-lang.org>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:109540] [Ruby master Bug#18751] Regression on master for Method#== when comparing public with private method
Date: Thu, 18 Aug 2022 09:30:26 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-98711.20220818093025.772@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-18751.20220423113947.772@ruby-lang.org
Issue #18751 has been updated by Eregon (Benoit Daloze).
We discussed this at the dev meeting.
@ko1 said Method#== should be "is it the same definition?".
I agree, I'll take a look at this with #18729 and #18435.
----------------------------------------
Bug #18751: Regression on master for Method#== when comparing public with private method
https://bugs.ruby-lang.org/issues/18751#change-98711
* 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)] # => [#<Method: #<Class:C>(Class)#new(*)>, #<Method: #<Class:C>(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/
next prev parent reply other threads:[~2022-08-18 9:30 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-23 11:39 [ruby-core:108378] [Ruby master Bug#18751] Regression on master for Method#== when comparing public with private method Eregon (Benoit Daloze)
2022-04-25 16:22 ` [ruby-core:108395] " jeremyevans0 (Jeremy Evans)
2022-04-25 17:19 ` [ruby-core:108396] " Eregon (Benoit Daloze)
2022-04-25 17:27 ` [ruby-core:108398] " Eregon (Benoit Daloze)
2022-05-17 6:51 ` [ruby-core:108577] " mame (Yusuke Endoh)
2022-05-17 10:00 ` [ruby-core:108581] " ioquatix (Samuel Williams)
2022-05-17 10:21 ` [ruby-core:108583] " Eregon (Benoit Daloze)
2022-05-17 15:41 ` [ruby-core:108596] " jeremyevans0 (Jeremy Evans)
2022-05-18 1:27 ` [ruby-core:108605] " mame (Yusuke Endoh)
2022-08-10 9:53 ` [ruby-core:109460] " Eregon (Benoit Daloze)
2022-08-15 13:22 ` [ruby-core:109486] " Eregon (Benoit Daloze)
2022-08-15 14:24 ` [ruby-core:109487] " Eregon (Benoit Daloze)
2022-08-18 9:30 ` Eregon (Benoit Daloze) [this message]
2022-08-20 11:46 ` [ruby-core:109589] " Eregon (Benoit Daloze)
2022-08-20 12:06 ` [ruby-core:109591] " Eregon (Benoit Daloze)
2022-12-01 5:49 ` [ruby-core:111107] " matz (Yukihiro Matsumoto)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-98711.20220818093025.772@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).