-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request NixOS#9754 from 9999years/print-value-when-coercio…
…n-fails Print the value in `error: cannot coerce` messages (cherry picked from commit 5b7bfd2) === test taken from 6e8d598; it was added previously (and not backported because its pr was a mostly-revert), but it's useful to have around. Change-Id: Icbd14b55e3610ce7b774667bf14b82e6dc717982
- Loading branch information
eldritch horrors
committed
Mar 9, 2024
1 parent
2f7c3fa
commit 609a8e0
Showing
10 changed files
with
84 additions
and
29 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,24 @@ | ||
--- | ||
synopsis: Coercion errors include the failing value | ||
issues: #561 | ||
prs: #9754 | ||
--- | ||
|
||
The `error: cannot coerce a <TYPE> to a string` message now includes the value | ||
which caused the error. | ||
|
||
Before: | ||
|
||
``` | ||
error: cannot coerce a set to a string | ||
``` | ||
|
||
After: | ||
|
||
``` | ||
error: cannot coerce a set to a string: { aesSupport = «thunk»; | ||
avx2Support = «thunk»; avx512Support = «thunk»; avxSupport = «thunk»; | ||
canExecute = «thunk»; config = «thunk»; darwinArch = «thunk»; darwinMinVersion | ||
= «thunk»; darwinMinVersionVariable = «thunk»; darwinPlatform = «thunk»; «84 | ||
attributes elided»} | ||
``` |
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
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
9 changes: 9 additions & 0 deletions
9
tests/functional/lang/eval-fail-bad-string-interpolation-4.err.exp
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,9 @@ | ||
error: | ||
… while evaluating a path segment | ||
at /pwd/lang/eval-fail-bad-string-interpolation-4.nix:9:3: | ||
8| # The error message should not be too long. | ||
9| ''${pkgs}'' | ||
| ^ | ||
10| | ||
|
||
error: cannot coerce a set to a string: { a = { a = { a = { a = "ha"; b = "ha"; c = "ha"; d = "ha"; e = "ha"; f = "ha"; g = "ha"; h = "ha"; j = "ha"; }; «4294967295 attributes elided»}; «4294967294 attributes elided»}; «4294967293 attributes elided»} |
9 changes: 9 additions & 0 deletions
9
tests/functional/lang/eval-fail-bad-string-interpolation-4.nix
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,9 @@ | ||
let | ||
# Basically a "billion laughs" attack, but toned down to simulated `pkgs`. | ||
ha = x: y: { a = x y; b = x y; c = x y; d = x y; e = x y; f = x y; g = x y; h = x y; j = x y; }; | ||
has = ha (ha (ha (ha (x: x)))) "ha"; | ||
# A large structure that has already been evaluated. | ||
pkgs = builtins.deepSeq has has; | ||
in | ||
# The error message should not be too long. | ||
''${pkgs}'' |
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