-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behavioriterationInvolves iteration or the iteration protocolInvolves iteration or the iteration protocol
Description
julia> collection_of_iterators = [Iterators.map(identity, 3), Iterators.map(sqrt, 3)];
julia> Base.IteratorSize.(collection_of_iterators)
2-element Vector{Base.HasShape{0}}:
Base.HasShape{0}()
Base.HasShape{0}()
julia> Base.IteratorSize(eltype(collection_of_iterators)) # incorrect, hits the fallback method
Base.HasLength()
There are two correct options for the return type here:
HasShape{0}
: precise and accurateSizeUnknown
: imprecise, but still accurate
The fix should be simple, this is the relevant method, just need to relax the dispatch:
Line 101 in 772745b
IteratorSize(::Type{Generator{I,F}}) where {I,F} = IteratorSize(I) |
NB: This is perhaps part of a wider issue of HasLength
not being a correct fallback, but that's a separate topic.
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behavioriterationInvolves iteration or the iteration protocolInvolves iteration or the iteration protocol