-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Description
I believe this overflow is unwanted.
julia> I = 1:2:typemax(Int)
1:2:9223372036854775807
julia> iterate(I, last(I))
julia> iterate(I, last(I)-1)
(-9223372036854775808, -9223372036854775808)
julia> iterate(I, last(I)-2)
(9223372036854775807, 9223372036854775807)Another behavior that might be related to this:
julia> iterate(Base.OneTo(5), 6)
(7, 7)Should this return nothing or (7, 7)?
Related lines are:
Lines 651 to 664 in 9392bbe
| function iterate(r::Union{LinRange,StepRangeLen}, i::Int=1) | |
| @_inline_meta | |
| length(r) < i && return nothing | |
| unsafe_getindex(r, i), i + 1 | |
| end | |
| iterate(r::OrdinalRange) = isempty(r) ? nothing : (first(r), first(r)) | |
| function iterate(r::OrdinalRange{T}, i) where {T} | |
| @_inline_meta | |
| i == last(r) && return nothing | |
| next = convert(T, i + step(r)) | |
| (next, next) | |
| end |
Metadata
Metadata
Assignees
Labels
No labels