super: no superclass method in Ruby 2.1.1
Below code will result into error:
super: no superclass method `foo' for #<Object:0x002b0430670fe8>
However, it can pass with Ruby 1.9 and I am not sure if it's feature changes or bug.
module A def foo puts "A" end end module B def foo puts "B" super end ub_meth = instance_method :foo define_method :foo do ub_meth.bind(self).call() end end a = Object.new a.extend A a.extend B a.foo
Updated by nobu (Nobuyoshi Nakada) about 6 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
Applied in changeset r45565.
proc.c: fix super in bound UnboundMethod
- proc.c (rb_method_call_with_block, umethod_bind): call with IClass including the module for a module instance method. [ruby-core:61936] [Bug #9721]
- vm_insnhelper.c (vm_search_super_method): allow bound UnboundMethod case.
Updated by wehu (Wei Hu) about 6 years ago
Thanks for your fix, but this still has problem. If we run my original example, it will result into:
B B B t.rb:9: stack level too deep (SystemStackError)
I think the difference is: in the original example, I used
define_method :foo to override the foo in Module