Parameters.jl icon indicating copy to clipboard operation
Parameters.jl copied to clipboard

Better backtraces

Open mauro3 opened this issue 9 years ago • 5 comments
trafficstars

Use the trick Tim used in https://github.com/mauro3/SimpleTraits.jl/pull/6 to get better backtraces.

mauro3 avatar Aug 10 '16 19:08 mauro3

Probably use https://bramtayl.github.io/NumberedLines.jl/stable/

mauro3 avatar Feb 09 '17 09:02 mauro3

I started trying to work on this but I think the code surgery got a little out of hand. One reasonable first step would be to use MacroTools exclusively for expression decomposition. Then I could write a wrappers for macrotools such that any numbered line inputs will yield numbered line outputs. Then comes the question of how to put these pieces together, that is, which part of the generated code you want to point back to which original line.

bramtayl avatar Mar 23 '17 17:03 bramtayl

Hi @bramtayl, thanks for looking into this! I'm not 100% sure that MacroTools will work for 100%, but using more MacroTools is definitely good. I think starting non-fancy and just referencing the first line of the type def would be fine.

But I'm off on holidays now and then crazy conference prep. So, don't expect much from me until the end of April.

mauro3 avatar Mar 23 '17 20:03 mauro3

I realized today I had been thinking about this wrong. It seems like you would want backtraces to point to lines in the Parameters.jl file in @with_kw and not to lines in user code (that should already be clear in the stack trace entry which points to the macrocall location). This is in fact already the case; if you @macroexpand @with_kw ... you'll see code chock full of references to lines in Parameters.jl.

bramtayl avatar Jul 05 '17 09:07 bramtayl

Thanks for spending your brain cycles on this!

There is probably a bit of both, but I think more the user-code (I assume that the Parameters.jl code is bug free ;-). Example:

julia> using Parameters                                                                                                                
                                                                                                                                       
julia> @with_kw type AA
       b=c
       end                                                                                                                             
AA                                                                                                                                     

julia> AA()                                                                                                                            
ERROR: UndefVarError: c not defined                                                                                                    
Stacktrace:                                                                                                                            
 [1] AA() at /home/mauro/.julia/v0.6/Parameters/src/Parameters.jl:376                                                                  

Here it would be better to point to the user-code.

mauro3 avatar Jul 05 '17 10:07 mauro3