Issue #7613 has been reported by zhangsu (Su Zhang). ---------------------------------------- Bug #7613: An Alias for a class method inherited from the Class class is not equal to the original method https://bugs.ruby-lang.org/issues/7613 Author: zhangsu (Su Zhang) Status: Open Priority: Normal Assignee: Category: core Target version: 1.9.3 ruby -v: ruby 1.9.3p327 (2012-11-10) [i386-mingw32] class Stream class << self alias_method :open, :new end end open = Stream.method(:open) new = Stream.method(:new) p open, new # => #<Method: Stream.new>, #<Method: Class#new> p open.receiver, new.receiver # => Stream, Stream p open == new # => false Expect the last line to return true, but got false. According to the documentation for `Method#==`: > Two method objects are equal if they are bound to the same object and refer to the same method definition. Here, `open` and `new` are all bound to `Stream` and I expect them to refer to the method definition too.
[ruby-trunk - Bug #7613][Open] An Alias for a class method inherited from the Class class is not equ
on 2012-12-23 22:40
on 2012-12-28 03:27
Issue #7613 has been updated by shugo (Shugo Maeda). zhangsu (Su Zhang) wrote: > p open == new # => false > > Expect the last line to return true, but got false. According to the documentation for `Method#==`: open == new returns false because their owners are different. p [open.owner, new.owner] #=> [#<Class:Stream>, Class] > > Two method objects are equal if they are bound to the same object and refer to the same method definition. > > Here, `open` and `new` are all bound to `Stream` and I expect them to refer to the method definition too. I've fixed the documentation of Method#== as follows: Two method objects are equal if they are bound to the same object and refer to the same method definition and their owners are the same class or module. ---------------------------------------- Bug #7613: An Alias for a class method inherited from the Class class is not equal to the original method https://bugs.ruby-lang.org/issues/7613#change-35117 Author: zhangsu (Su Zhang) Status: Closed Priority: Normal Assignee: Category: core Target version: 1.9.3 ruby -v: ruby 1.9.3p327 (2012-11-10) [i386-mingw32] class Stream class << self alias_method :open, :new end end open = Stream.method(:open) new = Stream.method(:new) p open, new # => #<Method: Stream.new>, #<Method: Class#new> p open.receiver, new.receiver # => Stream, Stream p open == new # => false Expect the last line to return true, but got false. According to the documentation for `Method#==`: > Two method objects are equal if they are bound to the same object and refer to the same method definition. Here, `open` and `new` are all bound to `Stream` and I expect them to refer to the method definition too.
on 2012-12-28 03:36
Issue #7613 has been updated by shugo (Shugo Maeda). shugo (Shugo Maeda) wrote: > open == new returns false because their owners are different. > > p [open.owner, new.owner] #=> [#<Class:Stream>, Class] I forgot to explain why Method#== returns false if owners are different. If owners of methods are different, the behavior of super is different in the methods, so Method#== should not return true for the methods. ---------------------------------------- Bug #7613: An Alias for a class method inherited from the Class class is not equal to the original method https://bugs.ruby-lang.org/issues/7613#change-35118 Author: zhangsu (Su Zhang) Status: Closed Priority: Normal Assignee: Category: core Target version: 1.9.3 ruby -v: ruby 1.9.3p327 (2012-11-10) [i386-mingw32] class Stream class << self alias_method :open, :new end end open = Stream.method(:open) new = Stream.method(:new) p open, new # => #<Method: Stream.new>, #<Method: Class#new> p open.receiver, new.receiver # => Stream, Stream p open == new # => false Expect the last line to return true, but got false. According to the documentation for `Method#==`: > Two method objects are equal if they are bound to the same object and refer to the same method definition. Here, `open` and `new` are all bound to `Stream` and I expect them to refer to the method definition too.
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.