lix/doc/manual/rl-next/source-positions-in-errors.md
Rebecca Turner 0b80935c22
Pass positions when evaluating
This includes position information in more places, making debugging
easier.

Before:

```
$ nix-instantiate --show-trace --eval tests/functional/lang/eval-fail-using-set-as-attr-name.nix
error:
       … while evaluating an attribute name

         at «none»:0: (source not available)

       error: value is a set while a string was expected
```

After:

```
error:
       … while evaluating an attribute name

         at /pwd/lang/eval-fail-using-set-as-attr-name.nix:5:10:

            4| in
            5|   attr.${key}
             |          ^
            6|

       error: value is a set while a string was expected
```
2023-12-07 10:27:21 -08:00

848 B

synopsis: Source locations are printed more consistently in errors issues: #561 prs: #9555 description: {

Source location information is now included in error messages more consistently. Given this code:

let
  attr = {foo = "bar";};
  key = {};
in
  attr.${key}

Previously, Nix would show this unhelpful message when attempting to evaluate it:

error:
       … while evaluating an attribute name

         at «none»:0: (source not available)

       error: value is a set while a string was expected

Now, the error message displays where the problematic value was found:

error:
       … while evaluating an attribute name

         at bad.nix:4:11:

            3|   key = {};
            4| in attr.${key}
             |           ^
            5|

       error: value is a set while a string was expected

}