An explanation of LoadError: DomainError:?


#1

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.


#2

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.


#3

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)).

#4

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