Improve AST-level source position tracking #2071
Labels
tech debt
Issues that document or involve technical debt
topics: error-handling
Issues involving the way SAW responds to an error condition
topics: error-messages
Issues involving the messages SAW produces on error
At the AST level (src/SAWScript/AST.hs) statements have source positions on each constructor, but expressions, patterns, and types are instead handled by having an extra constructor with just a position that's inserted at, in theory, strategic places to assure that position information is available. The idea is to use the next enclosing such position.
This doesn't actually work out very well. First, for type errors, one really wants the exact position of the exact expression that one's complaining about and not an approximation. Second, it's hard to use in practice (since it has to be carried around as pass state) and it's also hard to know in general what position you have and what it's actually the position of.
We decided this should be removed in favor of just storing positions in each constructor, at least for expressions and patterns. So far whether to extend this to types is TBD.
The text was updated successfully, but these errors were encountered: