Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetchTree: add pos to EvalState::forceValue #5396

Merged
merged 2 commits into from
Oct 17, 2021
Merged

Conversation

kamadorueda
Copy link
Member

  • Improve error messages on infinite recursion by displaying the nearest position
  • Demo:
    let x = builtins.fetchTree x;
    in x
    • Before:
      $ nix-instantiate --extra-experimental-features flakes --strict
      error: infinite recursion encountered
    • After:
      $ 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
  • Demo:
    let x = builtins.fetchTree {
      type = "git";
      inherit x;
    };
    in x
    • Before:
      $ nix-instantiate --extra-experimental-features flakes --strict
      error: infinite recursion encountered
    • After:
      $ nix-instantiate --extra-experimental-features flakes --strict
      error: infinite recursion encountered
      
           at /data/github/kamadorueda/nix/test.nix:3:10:
      
                2|   type = "git";
                3|   inherit x;
                 |          ^
                4| };

Mentions: #3505

- 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
- This way we improve error messages
  on infinite recursion
- Demo:
  ```nix
  let x = builtins.fetchTree {
    type = "git";
    inherit 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:3:10:

            2|   type = "git";
            3|   inherit x;
             |          ^
            4| };
  ```

Mentions: NixOS#3505
@domenkozar domenkozar assigned domenkozar and unassigned domenkozar Oct 16, 2021
@domenkozar
Copy link
Member

cc @bburdette

@edolstra edolstra merged commit 97b4904 into NixOS:master Oct 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants