Skip to content

Commit

Permalink
Provide informative error for eltype(Union{})
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Feb 11, 2017
1 parent 379f18e commit 7b332ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@ Int8
"""
eltype(::Type) = Any
eltype(::Type{Any}) = Any
eltype(::Type{Bottom}) = throw(ArgumentError("Union{} does not have elements"))
eltype(t::DataType) = eltype(supertype(t))
eltype(x) = eltype(typeof(x))

Expand Down
2 changes: 2 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4676,3 +4676,5 @@ if Sys.WORD_SIZE == 64
end
@test_nowarn tester20360()
end

@test_throws ArgumentError eltype(Bottom)

0 comments on commit 7b332ac

Please sign in to comment.