Project

General

Profile

Bug #9740

Updated by nobu (Nobuyoshi Nakada) over 10 years ago

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. 

 ~~~ruby 
 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` 'define_method :foo' to override the foo in Module `B`. B. 

Back