Actions
Bug #15889
closedEnumerator#each_slice size FloatDomainError with infinite enumerator
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-freebsd12.0]
Description
Calling #size
on an infinite each_slice
Enumerator results in a FloatDomainError
exception:
1.step.size # => Infinity
1.step.each_slice(2).size # => FloatDomainError
Traceback (most recent call last):
...
3: from (irb):3:in `size'
2: from (irb):3:in `div'
1: from (irb):3:in `floor'
FloatDomainError (Infinity)
Looks like enum_each_slice_size()
is missing a guard conditional prior to calling div_int()
with the slice size.
This was reported by Josh Cheek on Twitter: https://twitter.com/josh_cheek/status/1134123733445218304
Actions
Like0
Like0