Provide proper error location for antiquotations, turning big. #959
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.
I have been banging my head around a small annoyance with antiquotations. Because they do not have their own NExprF constructor, they receive no location annotation. This in turns prevents the display of the right antiquote in the error message.
Example of the error before:
And after this hack (including changes from #957 )
Of course, the hack appears in the pretty-print of the ast:
While evaluating: "${"${a}"}${"${b}"}"
. I simply wrapped the antiquotation into another string with a single antiquotation.This makes me think that having a proper
Antiquotation !r
constructor the NExprF datatype may help a lot. Because seen from this point of view, antiquotations are a grammatical marker for coercing an expression to a string. It fits quite well to mark the full antiquotation as the source of the problem when the value is not coercible to a string, because the expression itself is not faulty. I will investigate that idea.Some related questions remain, like why do we insist on keeping the indent level of multiline strings ? These are the only space-related information that we keep, and it is not at all used. It seems like an attempt to render values as closely as possible to the original input. But in many other locations we just drop the info. So it is an incomplete attempt (see how we handle the
let ... body =
construct.