Project

General

Profile

Actions

Bug #7806

closed

inconsistency between Method#inspect and Method#name

Added by Hanmac (Hans Mackowiak) about 11 years ago. Updated over 4 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
[ruby-core:52048]

Description

=begin
it seems that Method#inspect does some magic with alias methods

code:
class A
def xyz
end
alias ver xyz
end

p A.instance_method(:ver) #<UnboundMethod: A#xyz>
p A.instance_method(:ver).name #:ver

a=A.new
p a.method(:ver) #<Method: A#xyz>
p a.method(:ver).name #:ver

shouldn't the #(({inspect})) method use the #(({name})) one?

maybe #(({alias?})) and #(({alias_target})) and maybe (({inspect})) return something like ((%#<Method: A#ver(xyz)>%)) so it can be seen that the method is an alias?

PS: sorry i cant get the code tag working currectly

Updated by nobu (Nobuyoshi Nakada) about 11 years ago

  • Description updated (diff)
Actions #2

Updated by nobu (Nobuyoshi Nakada) about 11 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r39222.
Hans, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


proc.c: show the given name

  • proc.c (method_inspect): show the given name primarily, and
    original_id if aliased. [ruby-core:52048] [Bug #7806]

Updated by ko1 (Koichi Sasada) about 11 years ago

  • Status changed from Closed to Open
  • Assignee set to nobu (Nobuyoshi Nakada)
  • Target version set to 2.6

Nobu, you add new method Method#original_name on r39223.

Could you explain about it, why and what?

I make the target version of this ticket `next minor'.
If it should be applied to 2.0.0, please change it and make backport ticket.

Updated by nobu (Nobuyoshi Nakada) about 11 years ago

(13/02/14 10:38), ko1 (Koichi Sasada) wrote:

Nobu, you add new method Method#original_name on r39223.

Could you explain about it, why and what?

To obtain original method name, when the name is an alias.

I make the target version of this ticket `next minor'.
If it should be applied to 2.0.0, please change it and make backport ticket.

No, I don't think it needs to be backported.

--
Nobu Nakada

Actions #5

Updated by naruse (Yui NARUSE) over 6 years ago

  • Target version deleted (2.6)
Actions #6

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • Status changed from Open to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0