Project

General

Profile

Bug #10167

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

We expect `Prime` class implements `Module#include?(mod)`.    But `Prime#include?(mod)` hangs up, because it is overwritten by `Enumerable#include?(obj)` and tries to search `mod` linearly from infinite sequence of prime numbers. 


 **Reproducible script:** 

 ~~~ 
 $ ruby -e 'require "prime"; puts Prime.include?(Enumerable)' 
 ~~~ 

 * Expected: returns `true` 
 * Actual: hangs up 


 I found this bug by the following code (hangs up if prime is required) 

 ~~~ruby ~~~ 
 enumerables = [] 
 ObjectSpace.each_object(Class){|klass| 
   if klass.include?(Enumerable) then 
     enumerables.push klass 
   end 
 } 
 ~~~

Back