Bug #9740
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
Hi, Nakada,
Thanks for your fix @ r45565, 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 8 years ago
- Copied from Bug #9721: super: no superclass method in Ruby 2.1.1 added
Updated by wehu (Wei Hu) over 8 years ago
sorry, looks like it's fixed @ r45585. We can close this one. Thanks a lot, Nobuyoshi. :)
Updated by nobu (Nobuyoshi Nakada) over 8 years ago
- Description updated (diff)
- Status changed from Open to Closed
Updated by nobu (Nobuyoshi Nakada) over 8 years ago
I missed to include the reference in the commit log, but just in the test.
Updated by nagachika (Tomoyuki Chikanaga) over 8 years ago
The reference from r46005 was mistake. The changesets for this ticket were not backported yet. sorry for noise.
Updated by nagachika (Tomoyuki Chikanaga) about 8 years ago
- Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED to 2.0.0: REQUIRED, 2.1: DONE
r45585 was already backported into ruby_2_1
branch at r46190 for #9721.
Updated by usa (Usaku NAKAMURA) about 8 years ago
- Backport changed from 2.0.0: REQUIRED, 2.1: DONE to 2.0.0: DONE, 2.1: DONE
and also already backported into ruby_2_0_0
at r46157.