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

Make function arguments retain position info #3468

Merged
merged 1 commit into from Apr 8, 2020

Conversation

infinisil
Copy link
Member

This allows querying the location of function arguments. E.g.

builtins.unsafeGetAttrPos "x" (builtins.functionArgs ({ x }: null))

-> { column = 57; file = "/home/infinisil/src/nix/inst/test.nix"; line = 1; }

I'll be able to use this in NixOS/nixpkgs#79877 for better error messages

This allows querying the location of function arguments. E.g.

  builtins.unsafeGetAttrPos "x" (builtins.functionArgs ({ x }: null))

  => { column = 57; file = "/home/infinisil/src/nix/inst/test.nix"; line = 1; }
@domenkozar domenkozar added the error-messages Confusing messages and better diagnostics label Apr 3, 2020
@domenkozar domenkozar requested a review from edolstra April 3, 2020 08:21
@domenkozar
Copy link
Member

@edolstra any objections?

@edolstra edolstra merged commit 9ed097d into NixOS:master Apr 8, 2020
@infinisil infinisil deleted the functionArgsPositions branch April 9, 2020 10:42
@infinisil
Copy link
Member Author

Thx!

Profpatsch pushed a commit to infinisil/nixpkgs that referenced this pull request Mar 22, 2022
This uses the levenshtein distance to look through all possible
arguments to find ones that are close to what was requested:

  error: Function in /home/infinisil/src/nixpkgs/pkgs/tools/text/ripgrep/default.nix
    called without required argument "fetchFromGithub",
    did you mean "fetchFromGitHub" or "fetchFromGitLab"?

With NixOS/nix#3468 (in current nixUnstable) the error
message becomes even better, adding line location info
Profpatsch pushed a commit to NixOS/nixpkgs that referenced this pull request Apr 1, 2022
This uses the levenshtein distance to look through all possible
arguments to find ones that are close to what was requested:

  error: Function in /home/infinisil/src/nixpkgs/pkgs/tools/text/ripgrep/default.nix
    called without required argument "fetchFromGithub",
    did you mean "fetchFromGitHub" or "fetchFromGitLab"?

With NixOS/nix#3468 (in current nixUnstable) the error
message becomes even better, adding line location info
github-actions bot pushed a commit to arcnmx/nixpkgs-lib that referenced this pull request Apr 2, 2022
This uses the levenshtein distance to look through all possible
arguments to find ones that are close to what was requested:

  error: Function in /home/infinisil/src/nixpkgs/pkgs/tools/text/ripgrep/default.nix
    called without required argument "fetchFromGithub",
    did you mean "fetchFromGitHub" or "fetchFromGitLab"?

With NixOS/nix#3468 (in current nixUnstable) the error
message becomes even better, adding line location info
github-actions bot pushed a commit to nix-community/nixpkgs.lib that referenced this pull request Apr 3, 2022
This uses the levenshtein distance to look through all possible
arguments to find ones that are close to what was requested:

  error: Function in /home/infinisil/src/nixpkgs/pkgs/tools/text/ripgrep/default.nix
    called without required argument "fetchFromGithub",
    did you mean "fetchFromGitHub" or "fetchFromGitLab"?

With NixOS/nix#3468 (in current nixUnstable) the error
message becomes even better, adding line location info
github-actions bot pushed a commit to nix-community/nixpkgs.lib that referenced this pull request Dec 4, 2022
This uses the levenshtein distance to look through all possible
arguments to find ones that are close to what was requested:

  error: Function in /home/infinisil/src/nixpkgs/pkgs/tools/text/ripgrep/default.nix
    called without required argument "fetchFromGithub",
    did you mean "fetchFromGitHub" or "fetchFromGitLab"?

With NixOS/nix#3468 (in current nixUnstable) the error
message becomes even better, adding line location info
github-actions bot pushed a commit to nix-community/nixpkgs.lib that referenced this pull request May 31, 2023
This uses the levenshtein distance to look through all possible
arguments to find ones that are close to what was requested:

  error: Function in /home/infinisil/src/nixpkgs/pkgs/tools/text/ripgrep/default.nix
    called without required argument "fetchFromGithub",
    did you mean "fetchFromGitHub" or "fetchFromGitLab"?

With NixOS/nix#3468 (in current nixUnstable) the error
message becomes even better, adding line location info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error-messages Confusing messages and better diagnostics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants