File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -139,25 +139,25 @@ julia> unit(1.0) == NoUnits
139139true
140140```
141141"""
142-
143- """
144- This is shown if a user has not defined units for their quantity type.
145- """
146- const MISSING_UNIT_DEFINITION_MESSAGE =
147- """
148- You tried calling unit on an object that has none defined.
149- Not everything has (or should have) units.
150- If your type should have units, define a method of unit on them.
151- """
152-
153- @inline unit (x:: Any ) = throw ( DomainError ( x, MISSING_UNIT_DEFINITION_MESSAGE ) )
154- @inline unit (x:: Type{Any} ) = throw ( DomainError ( x, MISSING_UNIT_DEFINITION_MESSAGE ) )
155142@inline unit (x:: Number ) = NoUnits
156143@inline unit (x:: Type{T} ) where {T <: Number } = NoUnits
157144@inline unit (x:: Type{Union{Missing, T}} ) where T = unit (T)
158145@inline unit (x:: Type{Missing} ) = missing
159146@inline unit (x:: Missing ) = missing
160147
148+ """
149+ unit(::Type{Any})
150+
151+ This method is here to prevent infinite recursion and to provide a helpful error message in case it occurs.
152+ """
153+ @inline unit (x:: Type{Any} ) = throw ( ArgumentError (
154+ """
155+ The method unit(Any) was called, but this method has no meaningful result.
156+ The call may be due to calling unit(eltype(…)) on a container,
157+ since eltype has a generic fallback method that returns Any.
158+ """
159+ ) )
160+
161161"""
162162 absoluteunit(::Units)
163163 absoluteunit(::Quantity)
You can’t perform that action at this time.
0 commit comments