Skip to content

Commit ab0c6dd

Browse files
authored
Add missing type parameter to TakeWhile (#42958)
Without this `TakeWhile` has `eltype` of `Any`
1 parent 0771250 commit ab0c6dd

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

base/iterators.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ end
790790

791791
IteratorSize(::Type{<:TakeWhile}) = SizeUnknown()
792792
eltype(::Type{TakeWhile{I,P}} where P) where {I} = eltype(I)
793-
IteratorEltype(::Type{TakeWhile{I}} where P) where {I} = IteratorEltype(I)
793+
IteratorEltype(::Type{TakeWhile{I, P}} where P) where {I} = IteratorEltype(I)
794794

795795

796796
# dropwhile

test/iterators.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ end
212212
@test collect(takewhile(Returns(true),5:10)) == 5:10
213213
@test collect(takewhile(isodd,[1,1,2,3])) == [1,1]
214214
@test collect(takewhile(<(2), takewhile(<(3), [1,1,2,3]))) == [1,1]
215+
@test Base.IteratorEltype(typeof(takewhile(<(4),Iterators.map(identity, 1:10)))) isa Base.EltypeUnknown
215216
end
216217

217218
# dropwhile
@@ -224,6 +225,7 @@ end
224225
@test isempty(dropwhile(Returns(true), 1:3))
225226
@test collect(dropwhile(isodd,[1,1,2,3])) == [2,3]
226227
@test collect(dropwhile(iseven,dropwhile(isodd,[1,1,2,3]))) == [3]
228+
@test Base.IteratorEltype(typeof(dropwhile(<(4),Iterators.map(identity, 1:10)))) isa Base.EltypeUnknown
227229
end
228230

229231
# cycle

0 commit comments

Comments
 (0)