Skip to content

Commit

Permalink
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.fetchMercurial x;
  in
  x
  ```
- Before:
  ```bash
  $ nix-instantiate --show-trace --strict
  error: infinite recursion encountered
  ```
- After:
  ```bash
  nix-instantiate --show-trace --strict
  error: infinite recursion encountered

       at /data/github/kamadorueda/test/default.nix:2:7:

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

Mentions: NixOS#3505
  • Loading branch information
kamadorueda authored and dramforever committed Nov 27, 2021
1 parent 219c280 commit 069d4f5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libexpr/primops/fetchMercurial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static void prim_fetchMercurial(EvalState & state, const Pos & pos, Value * * ar
std::string name = "source";
PathSet context;

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

if (args[0]->type() == nAttrs) {

Expand Down

0 comments on commit 069d4f5

Please sign in to comment.