forked from lix-project/lix
eldritch horrors
87e6ac5eb7
Print the value in `value is X while a Y is expected` error
(cherry picked from commit 5f72a97092da6af28a7d2b2a50d74e9d34fae7e1)
Change-Id: Idb4bc903ae59a0f5b6fb3b1da4d47970fe0a6efe
32 lines
788 B
Markdown
32 lines
788 B
Markdown
---
|
|
synopsis: Better error reporting for `with` expressions
|
|
prs: 9658
|
|
---
|
|
|
|
`with` expressions using non-attrset values to resolve variables are now reported with proper positions.
|
|
|
|
Previously an incorrect `with` expression would report no position at all, making it hard to determine where the error originated:
|
|
|
|
```
|
|
nix-repl> with 1; a
|
|
error:
|
|
… <borked>
|
|
|
|
at «none»:0: (source not available)
|
|
|
|
error: value is an integer while a set was expected
|
|
```
|
|
|
|
Now position information is preserved and reported as with most other errors:
|
|
|
|
```
|
|
nix-repl> with 1; a
|
|
error:
|
|
… while evaluating the first subexpression of a with expression
|
|
at «string»:1:1:
|
|
1| with 1; a
|
|
| ^
|
|
|
|
error: expected a set but found an integer: 1
|
|
```
|