diff --git a/src/utils.jl b/src/utils.jl index 5adb9356..23efcfdc 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -145,6 +145,11 @@ true @inline unit(x::Type{Missing}) = missing @inline unit(x::Missing) = missing +# Prevent infinite recursion, in case unit(Any) is called. +@inline unit(x::Type{Any}) = throw(ArgumentError( + "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." +)) + """ absoluteunit(::Units) absoluteunit(::Quantity)