[#66126] Creation/Conversion methods/functions table for Ruby types — SASADA Koichi <ko1@...>
Hi,
5 messages
2014/11/07
[#66248] [ruby-trunk - Feature #10423] [PATCH] opt_str_lit*: avoid literal string allocations — normalperson@...
Issue #10423 has been updated by Eric Wong.
3 messages
2014/11/13
[#66595] [ruby-trunk - Bug #10557] [Open] Block not given when the argument is a string — bartosz@...
Issue #10557 has been reported by Bartosz Kopinski.
3 messages
2014/11/30
[ruby-core:66583] [ruby-trunk - Bug #10167] Prime#include?(mod) hangs up
From:
ruby-core@...
Date:
2014-11-30 05:34:27 UTC
List:
ruby-core #66583
Issue #10167 has been updated by Marc-Andre Lafortune.
Assignee set to Yuki Sonoda
Instead of aliasing `include?` to `prime?`, I'd recommend instead to restore it:
Prime.define_singleton_method(:include?, Module.instance_method(:include?))
Prime.include?(Enumerable) # => true
Probably won't be super useful, but still beats an infinite loop :-)
Assigning to yugui, although I have not seen any activity from her in over a year on the mailing list?
----------------------------------------
Bug #10167: Prime#include?(mod) hangs up
https://bugs.ruby-lang.org/issues/10167#change-50198
* Author: Kenichi Saita
* Status: Open
* Priority: Normal
* Assignee: Yuki Sonoda
* Category: lib
* Target version: current: 2.2.0
* ruby -v: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
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
}
~~~
---Files--------------------------------
prime-include.diff (1.21 KB)
--
https://bugs.ruby-lang.org/