From: shevegen@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:94375] [Ruby master Bug#16106] UnboundMethod owner points to base class
Date: Thu, 15 Aug 2019 23:10:32 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-80790.20190815231032.3b152eddb0128f06@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-16106.20190815202151@ruby-lang.org
Issue #16106 has been updated by shevegen (Robert A. Heiler).
I guess the documentation could mention that behaviour so that other
rubyists won't be confused, as alanwu pointed out e. g:
https://ruby-doc.org/core/UnboundMethod.html#method-i-owner
(Or the other documentation site; I just happen to find the above
more readily via a quick google search.)
On a side note, perhaps the name is not ideal, since I can see why
sbellware may be surprised - UnboundMethod implies to me a method
not attached to anywhere, so I was a bit surprised to see that it
still has a pointer to the original class from where it was created
from. Although I understand that this may be useful; it just seems
a bit peculiar to me ... perhaps it is a MostlyUnboundMethod. :P
----------------------------------------
Bug #16106: UnboundMethod owner points to base class
https://bugs.ruby-lang.org/issues/16106#change-80790
* Author: sbellware (Scott Bellware)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin17]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
This may not be a bug. It may be my misinterpretation of the feature.
When using UnboundMethod#owner on a class that was created with `Class.new(SomeBaseClass)`, the owner is reported as the `SomeBaseClass `rather than the new class.
This was a surprising outcome, since I presumed that the owner method would point to the class rather than the class's base class.
Example:
```
class SomeClass
def some_method
end
end
C = Class.new(SomeClass)
m = C.instance_method(:some_method)
pp m.owner
# => SomeClass
# I would have expected the owner to be C
```
Is this expected behavior?
Thanks,
Scott
---Files--------------------------------
unbound_method_owner_sketch.rb (176 Bytes)
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2019-08-15 23:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-16106.20190815202151@ruby-lang.org>
2019-08-15 20:21 ` [ruby-core:94372] [Ruby master Bug#16106] UnboundMethod owner points to base class sbellware
2019-08-15 20:39 ` [ruby-core:94373] " XrXr
2019-08-15 23:10 ` shevegen [this message]
2019-08-16 0:57 ` [ruby-core:94377] " sbellware
2019-09-09 23:55 ` [ruby-core:94880] " merch-redmine
2019-09-21 21:19 ` [ruby-core:95025] " eregontp
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-80790.20190815231032.3b152eddb0128f06@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).