Project

General

Profile

Actions

Bug #15444

closed

finite Ranges over Rationals are not iterable

Added by zvkemp (Zach Kemp) over 5 years ago. Updated over 5 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.6.0preview3 (2018-11-06 trunk 65578) [x86_64-linux]
[ruby-core:90648]

Description

Under 2.5.3, finite ranges over rational values are iterable, given a valid step size:

((1/10r)..(1/2r)).step(1/10r).to_a
# => [(1/10), (1/5), (3/10), (2/5), (1/2)]

Under 2.6.0, this is not the case (StopIteration is raised immediately)

((1/10r)..(1/2r)).step(1/10r).to_a
# => []

((1/10r)..(1/2r)).step(1/10r).next
# => StopIteration (iteration reached an end)

However, stepping over an infinite range in 2.6.0 works:

((1/10r)..).step(1/10r).take(5)
# => [(1/10), (1/5), (3/10), (2/5), (1/2)]

Also reproduced on x86_64-darwin17.

Updated by mrkn (Kenta Murata) over 5 years ago

  • Status changed from Open to Assigned
  • Assignee set to mrkn (Kenta Murata)
Actions #2

Updated by mrkn (Kenta Murata) over 5 years ago

  • Status changed from Assigned to Closed

Applied in changeset trunk|r66474.


enumerator.c: Fix airth_seq_each for Rational

Fix the wrong uses of rb_int_ge in arith_seq_each.

[ruby-core:90648] [Bug #15444]

Actions

Also available in: Atom PDF

Like0
Like0Like0