Bug #7806

inconsistency between Method#inspect and Method#name

Added by Hans Mackowiak about 1 year ago. Updated about 1 year ago.

[ruby-core:52048]
Status:Open
Priority:Normal
Assignee:Nobuyoshi Nakada
Category:-
Target version:next minor
ruby -v:ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] Backport:

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.instancemethod(:ver) #
p A.instance
method(:ver).name #:ver

a=A.new
p a.method(:ver) #
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 ((%#%)) so it can be seen that the method is an alias?

PS: sorry i cant get the code tag working currectly

Associated revisions

Revision 39222
Added by Nobuyoshi Nakada about 1 year ago

proc.c: show the given name

  • proc.c (methodinspect): show the given name primarily, and originalid if aliased. [Bug #7806]

Revision 39223
Added by Nobuyoshi Nakada about 1 year ago

proc.c: original_name

  • proc.c (methodoriginalname): new methods Method#originalname and UnboundMethod#originalname. [Bug #7806] [EXPERIMENTAL]

History

#1 Updated by Nobuyoshi Nakada about 1 year ago

  • Description updated (diff)

#2 Updated by Nobuyoshi Nakada about 1 year 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 (methodinspect): show the given name primarily, and originalid if aliased. [Bug #7806]

#3 Updated by Koichi Sasada about 1 year ago

  • Status changed from Closed to Open
  • Assignee set to Nobuyoshi Nakada
  • Target version set to next minor

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.

#4 Updated by Nobuyoshi Nakada about 1 year 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

Also available in: Atom PDF