-
-
Notifications
You must be signed in to change notification settings - Fork 398
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
errors inside macros give incorrect line numbers #7
Comments
The 'true' issue is JuliaLang/julia#1334, still open |
Unfortunately not fixed after JuliaLang/julia#12544: using JuMP
m = Model()
@setObjective(m, Max, z) and I get
|
Ouch, no luck on this yet? It's rather annoying :( |
We may have to restructure the macros to take advantage of the recent improvements, but I haven't looked into it. |
@ihnorton, I didn't follow all of the nuances of JuliaLang/julia#12544, but what do we have to do in JuMP to get call site line numbers reported correctly? |
You want it to report To clarify, 12544 is about getting correct line numbers when generated code throws an error. If I am understanding the situation here, the error is being thrown during macro expansion, so none of the generated code is actually running yet. See the second part of my comment here about errors during macro expansion (can't throw across the flisp stack). This PR is relevant, although I think I might be able to get you |
Yes, the example should run with vanilla JuMP.
|
@ihnorton, the error is at run time, not macro expansion. |
Thanks. With the simplified example, 12544 doesn't apply because the error is being thrown by the interpreter. JuliaLang/julia#13444 should help there. I assume you also want to use these macros inside of functions, where 12544 would apply, however, the location will still be off because I haven't figured out how to track the top-level location properly with nested locations, so right now we just default to the starting line number of the function body. |
I definitely get a better backtrace when I put the code into a function: using JuMP
function foo()
m = Model()
@setObjective(m, Max, z)
end
foo() gives
Though it's pointing to line 601 from dummy.jl which doesn't exist, it's macros.jl:601. |
With JuliaLang/julia#13431 that should show as |
@ihnorton, on master I'm now getting:
|
This seems to basically be fixed now? If we find another instance of bad backtraces we can open a new issue. |
use NaNMath package to return NaNs instead of throwing DomainErrors
In
dummy.jl
:Then:
The text was updated successfully, but these errors were encountered: