Project

General

Profile

Bug #9626

Updated by nobu (Nobuyoshi Nakada) almost 10 years ago

```ruby 
 module M 
   def foo 
     super 
   end 
 end 

 class C 
   def foo 
     'C#foo' 
   end 

   prepend M 
   alias_method :orig_foo, :foo 
   def foo 
     orig_foo 
   end 
 end 

 C.new.foo 
 ``` 

 I expect: `M#foo` M#foo -> `C#foo` C#foo -> `C#orig_foo` C#orig_foo and get `'C#foo'` 'C#foo' 
 Actual: `M#foo` M#foo -> `C#foo` C#foo -> `M#foo` M#foo -> ... and get `stack level too deep (SystemStackError)` 
 If I swap the order of `alias_method` and `prepend`, it works as I expect. 

 I think it's closely related to #7842.

Back