Actions
Bug #9721
closedsuper: no superclass method in Ruby 2.1.1
Description
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) over 10 years ago
- Description updated (diff)
- Category set to core
- Target version set to 2.2.0
- Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: REQUIRED, 2.1: REQUIRED
Updated by nobu (Nobuyoshi Nakada) over 10 years ago
- Description updated (diff)
Updated by nobu (Nobuyoshi Nakada) over 10 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) over 10 years ago
Hi, Nakada,
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 B
.
Updated by wehu (Wei Hu) over 10 years ago
- Copied to Bug #9740: super: no superclass method in Ruby 2.1.1 added
Updated by usa (Usaku NAKAMURA) over 10 years ago
Backported r45564, r45565, r45584 and r45585 into ruby_2_0_0 at r46157.
Updated by usa (Usaku NAKAMURA) over 10 years ago
- Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED to 2.0.0: DONE, 2.1: REQUIRED
Updated by nagachika (Tomoyuki Chikanaga) over 10 years ago
- Backport changed from 2.0.0: DONE, 2.1: REQUIRED to 2.0.0: DONE, 2.1: DONE
r45179, r45564, r45565, r45584 and r45585 were backported into ruby_2_1
branch at r46190.
Actions
Like0
Like0Like0Like0Like0Like0Like0Like0Like0