An explanation of LoadError: DomainError:?


DomainError help is:

The arguments to a function or constructor are outside the valid domain.

But I’m not sure of what constitutes “valid” and what the “domain” is?

I’m passing passing a macro generated struct as a argument between functions in different modules, and getting a domain error on some functions but not others with identical type signatures. It doesn’t give any indication of what the true problem is other than LoadError: DomainError: and a backtrace.


That’s up to the function. Eg for sqrt, the valid domain is positive real numbers.

Providing a minimal working example would allow giving you more specific advice.


Error on 0.7 is better, e.g.

julia> sqrt(-1)
ERROR: DomainError with -1.0:
sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).


Yes it was a square root in the end. That is a much better message in 0.7!