Skip to content

Commit

Permalink
fetchTree: add pos to EvalState::forceValue
Browse files Browse the repository at this point in the history
- This way we improve error messages
  on infinite recursion
- Demo:
  ```nix
  let x = builtins.fetchTree x;
  in x
  ```
- Before:
  ```bash
  $ nix-instantiate --extra-experimental-features flakes --strict
  error: infinite recursion encountered
  ```
- After:
  ```bash
  $ nix-instantiate --extra-experimental-features flakes --strict
  error: infinite recursion encountered

       at /data/github/kamadorueda/nix/test.nix:1:9:

            1| let x = builtins.fetchTree x;
             |         ^
            2| in x
  ```

Mentions: NixOS#3505
  • Loading branch information
kamadorueda authored and dramforever committed Nov 27, 2021
1 parent aa32b86 commit 3488c54
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libexpr/primops/fetchTree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static void fetchTree(
fetchers::Input input;
PathSet context;

state.forceValue(*args[0]);
state.forceValue(*args[0], pos);

if (args[0]->type() == nAttrs) {
state.forceAttrs(*args[0], pos);
Expand Down

0 comments on commit 3488c54

Please sign in to comment.