-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Print the value in
error: cannot coerce
messages
This extends the `error: cannot coerce a TYPE to a string` message to print the value that could not be coerced. This helps with debugging by making it easier to track down where the value is being produced from, especially in errors with deep or unhelpful stack traces.
- Loading branch information
Showing
6 changed files
with
61 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
synopsis: Prints the failing value in `error: cannot coerce` messages | ||
issues: #561 | ||
prs: #9553 | ||
description: { | ||
|
||
The `error: cannot coerce a <TYPE> to a string` message now includes the value | ||
which caused the error. This makes debugging much easier: | ||
|
||
``` | ||
$ nix repl nixpkgs | ||
nix-repl> nixpkgs = legacyPackages.x86_64-linux.path | ||
nix-repl> system = { system = "x86_64-linux"; } | ||
nix-repl> import nixpkgs { inherit system; } | ||
error: | ||
… while evaluating a branch condition | ||
at /nix/store/7g8wbm1z6948x0qma4hzkkb9a3xys76w-source/pkgs/stdenv/booter.nix:64:9: | ||
63| go = pred: n: | ||
64| if n == len | ||
| ^ | ||
65| then rnul pred | ||
… while calling the 'length' builtin | ||
at /nix/store/7g8wbm1z6948x0qma4hzkkb9a3xys76w-source/pkgs/stdenv/booter.nix:62:13: | ||
61| let | ||
62| len = builtins.length list; | ||
| ^ | ||
63| go = pred: n: | ||
(stack trace truncated; use '--show-trace' to show the full trace) | ||
error: cannot coerce a set to a string: { system = "x86_64-linux"; } | ||
``` | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ error: | |
| ^ | ||
2| | ||
|
||
error: cannot coerce a function to a string | ||
error: cannot coerce a function to a string: <LAMBDA> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ error: | |
| ^ | ||
2| | ||
|
||
error: cannot coerce a function to a string | ||
error: cannot coerce a function to a string: <LAMBDA> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters