Provide proper error location for antiquotations, turning big.#959
Provide proper error location for antiquotations, turning big.#959layus wants to merge 2 commits intohaskell-nix:masterfrom
Conversation
|
Some nice ideas in here, but introducing NAntiquotation is not one of them :-). Nix has an ExprConcatStrings expression, which is a shortcut for a chain of Hnix tries to go a bit too fast here by mangling the string concatenation with raw string expressions. Technically, in nix, double-quoted strings and indented strings do not exist. There exists only concatenations of raw strings and antiquotations. |
|
Not a solution but notifications & related thoughts. I refactored |
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 !rconstructor 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.