Skip to content

Commit

Permalink
fetch: nicer infinite recursion errors
Browse files Browse the repository at this point in the history
- This change applies to builtins.fetchurl and builtins.fetchTarball
- PoC: `let x = builtins.fetchurl 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.fetchurl x; in x
             |         ^
  ```

Mentions: NixOS#3505
  • Loading branch information
kamadorueda authored and dramforever committed Nov 27, 2021
1 parent ac825be commit f6ba47c
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 @@ -189,7 +189,7 @@ static void fetch(EvalState & state, const Pos & pos, Value * * args, Value & v,
std::optional<std::string> url;
std::optional<Hash> expectedHash;

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

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

Expand Down

0 comments on commit f6ba47c

Please sign in to comment.