Skip to content

Commit 7617229

Browse files
pepijndevosKristofferC
authored andcommitted
Add missing type parameter to TakeWhile (#42958)
Without this `TakeWhile` has `eltype` of `Any` (cherry picked from commit ab0c6dd)
1 parent 82af540 commit 7617229

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
@@ -786,7 +786,7 @@ end
786786

787787
IteratorSize(::Type{<:TakeWhile}) = SizeUnknown()
788788
eltype(::Type{TakeWhile{I,P}} where P) where {I} = eltype(I)
789-
IteratorEltype(::Type{TakeWhile{I}} where P) where {I} = IteratorEltype(I)
789+
IteratorEltype(::Type{TakeWhile{I, P}} where P) where {I} = IteratorEltype(I)
790790

791791

792792
# dropwhile

test/iterators.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ end
202202
@test collect(takewhile(Returns(true),5:10)) == 5:10
203203
@test collect(takewhile(isodd,[1,1,2,3])) == [1,1]
204204
@test collect(takewhile(<(2), takewhile(<(3), [1,1,2,3]))) == [1,1]
205+
@test Base.IteratorEltype(typeof(takewhile(<(4),Iterators.map(identity, 1:10)))) isa Base.EltypeUnknown
205206
end
206207

207208
# dropwhile
@@ -214,6 +215,7 @@ end
214215
@test isempty(dropwhile(Returns(true), 1:3))
215216
@test collect(dropwhile(isodd,[1,1,2,3])) == [2,3]
216217
@test collect(dropwhile(iseven,dropwhile(isodd,[1,1,2,3]))) == [3]
218+
@test Base.IteratorEltype(typeof(dropwhile(<(4),Iterators.map(identity, 1:10)))) isa Base.EltypeUnknown
217219
end
218220

219221
# cycle

0 commit comments

Comments
 (0)