Project

General

Profile

Actions

Bug #15889

closed

Enumerator#each_slice size FloatDomainError with infinite enumerator

Added by Freaky (Thomas Hurst) over 5 years ago. Updated over 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-freebsd12.0]
[ruby-core:92894]

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

Also available in: Atom PDF

Like0
Like0