-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
which field is causing the InexactError? #26475
Comments
Note that this has been changed on master (#20005) and julia> foo()
ERROR: InexactError: UInt16(UInt16, 1.1)
Stacktrace:
[1] Type at ./float.jl:668 [inlined]
[2] convert at ./number.jl:7 [inlined]
[3] setindex! at ./array.jl:699 [inlined]
[4] copyto!(::IndexLinear, ::Array{UInt16,1}, ::IndexLinear, ::Array{Float64,1}) at ./abstractarray.jl:711
[5] copyto! at ./abstractarray.jl:703 [inlined]
[6] Type at ./array.jl:426 [inlined]
[7] convert at ./array.jl:418 [inlined]
[8] Type at ./REPL[1]:2 [inlined]
[9] foo() at ./REPL[2]:1
[10] top-level scope
julia> bar()
ERROR: InexactError: Int64(Int64, 1.1)
Stacktrace:
[1] Type at ./float.jl:689 [inlined]
[2] convert at ./number.jl:7 [inlined]
[3] Type at ./REPL[1]:2 [inlined]
[4] bar() at ./REPL[3]:1
[5] top-level scope |
The printing |
The current (1.8.3) error message seems pretty good to me now:
which makes it immediately clear that the problem is specifically trying to call the Similarly for
I think that's good enough we can consider this completed finally, but of course reopen if anyone disagrees! |
Consider
These error messages are pretty hard to interpret, you need to at look at the line indicated in [3] to figure out that the problem is in a call to a constructor of
A
. Then it's not clear what field is involved. It would be really nice if the call signature toA
was shown (as is the case if I don't wrap these in functions), egand it would be extra nice if there was a line that indicated the which field was involved. In this case it's actually not too hard to figure out which field is the problem from the messages, but for a
struct
with lots of fields deep in some code, it can feel very opaque.The text was updated successfully, but these errors were encountered: