[ruby-core:90649] [Ruby trunk Bug#15444][Assigned] finite Ranges over Rationals are not iterable

From: muraken@...
Date: 2018-12-20 23:22:31 UTC
List: ruby-core #90649
Issue #15444 has been updated by mrkn (Kenta Murata).

Status changed from Open to Assigned
Assignee set to mrkn (Kenta Murata)

----------------------------------------
Bug #15444: finite Ranges over Rationals are not iterable
https://bugs.ruby-lang.org/issues/15444#change-75815

* Author: zvkemp (Zach Kemp)
* Status: Assigned
* Priority: Normal
* Assignee: mrkn (Kenta Murata)
* Target version: 
* ruby -v: ruby 2.6.0preview3 (2018-11-06 trunk 65578) [x86_64-linux]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
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.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next