ics-jku / wal

WAL enables programmable waveform analysis.
https://wal-lang.org
BSD 3-Clause "New" or "Revised" License
131 stars 18 forks source link

Report line number for runtime errors #18

Closed bauersimon closed 10 months ago

bauersimon commented 1 year ago

It can be challenging to figure out where a runtime error is coming from (especially for non-trivial wal scripts). Usually, the name of the problematic operation is supplied with the error message. However, it can still take quite a while to pin-point what's wrong.

I already investigated a bit how this could be done. In the reader.py calling Lark(propagate_positions=True) adds position information to the parse tree. The question is how to continue from there once the tree is transformed into wal internal structures.

I guess it would be enough to somehow attach line information to operators for the beginning, as those are very likely responsible for runtime errors. The question remains how to achieve this? Maybe introducing a wrapper AstNode that can hold the position information or a separate map that connects operations (essentially the [Operator, args...] since python lists are references) to line numbers. Maybe the SEval.eval would be a good location to catch any arising exceptions and attach the problematic line number to them.

LucasKl commented 1 year ago

Yes better error messages are probably one of the most important features right now. Thanks also for your thoughts on this, I already did some work in this direction using something like an AstNode and hope to be able to release that soon.

bauersimon commented 1 year ago

Since you're working on this, I also noticed that the error message when trying to load a waveform from a non-existent file the message is quite unfortunate:

(load "bar.fst" <foo>)

cannot access local variable 'signals' where it is not associated with a value

LucasKl commented 10 months ago

Closing, since this is now finally implemented.