Issue #8546 has been updated by Jim Gay.


Nobuyoshi Nakada wrote:
> Fixed in 2.1.

I tried the above sample code in 2.1.2 and the error has changed from a TypeError to a NoMethodError: "NoMethodError: super: no superclass method `hello' for #<O:0x007fb799046c50>"
Is that the fix?
From my perspective it would be not a fix but a refusal to implement using super when binding an UnboundMethod to an object. Have I misunderstood something?

----------------------------------------
Feature #8546: super errors in UnboundMethods
https://bugs.ruby-lang.org/issues/8546#change-48078

* Author: Jim Gay
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
`UnboundMethod`s are unable to call `super`

~~~ruby
module M
  def hello
    puts "hello from M"
  end
end

class O
  def hello
    puts "hello"
  end
end

o = O.new
o.hello #=> "hello"
M.instance_method(:hello).bind(o).call #=> "hello from M"

module M
  def hello
    super
  end
end

M.instance_method(:hello).bind(o).call #=> TypeError: self has wrong type to call super in this context: O (expected M)}))
~~~

Given that the non-super method works, I would expect super to work.




-- 
https://bugs.ruby-lang.org/