Project

General

Profile

Bug #7643

Updated by nobu (Nobuyoshi Nakada) almost 12 years ago

=begin 
 When (({define_method})) define_method is used within the refine block argument, calls to super will result in a stack level too deep. Definitions with def can call super without problems. 

   module 

 (({module A 
     
   refine Fixnum do 
       
     %i(+ -).each do |m| 
         
       define_method m do |other| 
           
         super(other) 
         end 
       end 

       
     end 
    
     def * other 
         
       super(other) 
       end 
     end 
   end 

   
 end 

 class B 
     
   using A 

     
  
   def working 
       
     puts 'working' 
       
     1 * 1 
     
   end 

     
  
   def error 
       
     puts 'stack level too deep' 
       
     1 + 1 
     
   end 

   
  
 end 

   

 puts B.new.working 
   
 puts B.new.error B.new.error})) 

 =end 

Back