Skip to content

Commit d14ad5b

Browse files
authored
Prevent infinite recursion by adding a method unit(::Type{Any}) (#807)
1 parent f860859 commit d14ad5b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/utils.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ true
145145
@inline unit(x::Type{Missing}) = missing
146146
@inline unit(x::Missing) = missing
147147

148+
# Prevent infinite recursion, in case unit(Any) is called.
149+
@inline unit(x::Type{Any}) = throw(ArgumentError(
150+
"unit(Any) was called, which has no meaningful result. This may be due to calling unit(eltype(…)), since eltype has a generic fallback method that returns Any."
151+
))
152+
148153
"""
149154
absoluteunit(::Units)
150155
absoluteunit(::Quantity)

0 commit comments

Comments
 (0)