Forum: Ruby-core [ruby-trunk - Bug #7806][Open] inconsistency between Method#inspect and Method#name

D9ebdcb66f1583378e6f72155db507e2?d=identicon&s=25 Hans Mackowiak (hanmac)
on 2013-02-08 23:44
(Received via mailing list)
Issue #7806 has been reported by Hanmac (Hans Mackowiak).

----------------------------------------
Bug #7806: inconsistency between Method#inspect and Method#name
https://bugs.ruby-lang.org/issues/7806

Author: Hanmac (Hans Mackowiak)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]


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
F1d6cc2b735bfd82c8773172da2aeab9?d=identicon&s=25 Nobuyoshi Nakada (nobu)
on 2013-02-12 13:49
(Received via mailing list)
Issue #7806 has been updated by nobu (Nobuyoshi Nakada).

Description updated


----------------------------------------
Bug #7806: inconsistency between Method#inspect and Method#name
https://bugs.ruby-lang.org/issues/7806#change-36167

Author: Hanmac (Hans Mackowiak)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]


=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
C4e88907313843cf07f6d85ba8162120?d=identicon&s=25 ko1 (Koichi Sasada) (Guest)
on 2013-02-14 02:39
(Received via mailing list)
Issue #7806 has been updated by ko1 (Koichi Sasada).

Status changed from Closed to Open
Assignee set to nobu (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.

----------------------------------------
Bug #7806: inconsistency between Method#inspect and Method#name
https://bugs.ruby-lang.org/issues/7806#change-36268

Author: Hanmac (Hans Mackowiak)
Status: Open
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category:
Target version: next minor
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]


=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
F1d6cc2b735bfd82c8773172da2aeab9?d=identicon&s=25 Nobuyoshi Nakada (nobu)
on 2013-02-14 03:31
(Received via mailing list)
(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.
This topic is locked and can not be replied to.