Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Previously I thought we wouldn't be able to get the correct locations of bindings for printing errors, but found we were actually stripping them during component minimization. This propagates the annotations so we can improve the location of unused bindings errors (and any other diagnostics which reference bindings in the future).
Old:
New:
Implementation notes
Abs
nodes to be the annotation of the actual variableInteresting/controversial decisions
This does remove the invariant I had previously held where every node's annotations contains everything inside, but I think it's worth it to gain this functionality. I just special-cased the other commands to know to ignore the Abs annotation when looking things up.
Ideally I'd just have a spot to put a distinct annotation for variable bindings, but I can't do that without changing either the Term or the ABT which is a ton of work and would maybe affect hashing. Maybe we can address this when we do the next re-hash migration.
Test coverage
Added some clever tests where you can mark the expected diagnostic location for a given error.
Loose ends
The let-binding error still spans the entire binding rather than just the name. I think I can fix this by threading another annotation through the Unison File, but that's a bigger change for a pretty small value-add, so I'll leave that for later.