Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions base/missing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -457,3 +457,6 @@ macro coalesce(args...)
end
return :(let val; $expr; end)
end

eltype(::Missing) = Any # imprecise but correct approximation for the element type of an unknown iterator
eltype(::Type{<:Union{Nothing, Missing}}) = throw(ArgumentError("not an iterator, doesn't have an element type"))
8 changes: 8 additions & 0 deletions test/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,14 @@ end
end
end

@testset "noniterator has no element type" begin
for x ∈ (nothing, missing)
@test_throws ArgumentError eltype(x)
@test_throws ArgumentError eltype(typeof(x))
end
@test_throws ArgumentError eltype(Union{Nothing, Missing})
end

@testset "Iterators docstrings" begin
@test isempty(Docs.undocumented_names(Iterators))
end
Loading