-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
builtins.genericClosure: improve errors
#14499
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
18 changes: 18 additions & 0 deletions
18
tests/functional/lang/eval-fail-genericClosure-deeply-nested-element.err.exp
This file contains hidden or 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,18 @@ | ||
| error: | ||
| … while calling the 'seq' builtin | ||
| at /pwd/lang/eval-fail-genericClosure-deeply-nested-element.nix:25:1: | ||
| 24| in | ||
| 25| builtins.seq finiteVal ( | ||
| | ^ | ||
| 26| builtins.genericClosure { | ||
|
|
||
| … while calling the 'genericClosure' builtin | ||
| at /pwd/lang/eval-fail-genericClosure-deeply-nested-element.nix:26:3: | ||
| 25| builtins.seq finiteVal ( | ||
| 26| builtins.genericClosure { | ||
| | ^ | ||
| 27| startSet = [ | ||
|
|
||
| … in genericClosure element { finite = { a0 = { a1 = { a2 = { a3 = { a4 = { a5 = { a6 = { a7 = { a8 = { ... }; }; }; }; }; }; }; }; }; }; «1 attribute elided» } | ||
|
|
||
| error: attribute 'key' missing |
35 changes: 35 additions & 0 deletions
35
tests/functional/lang/eval-fail-genericClosure-deeply-nested-element.nix
This file contains hidden or 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,35 @@ | ||
| let | ||
| finite = { | ||
| a0 = { | ||
| a1 = { | ||
| a2 = { | ||
| a3 = { | ||
| a4 = { | ||
| a5 = { | ||
| a6 = { | ||
| a7 = { | ||
| a8 = { | ||
| a9 = "deep"; | ||
| }; | ||
| }; | ||
| }; | ||
| }; | ||
| }; | ||
| }; | ||
| }; | ||
| }; | ||
| }; | ||
| }; | ||
| finiteVal = builtins.deepSeq finite finite; | ||
| in | ||
| builtins.seq finiteVal ( | ||
| builtins.genericClosure { | ||
| startSet = [ | ||
| { | ||
| infinite = import ./infinite-nesting.nix; | ||
| finite = finiteVal; | ||
| } | ||
| ]; | ||
| operator = x: [ (import ./infinite-nesting.nix) ]; | ||
| } | ||
| ) |
10 changes: 10 additions & 0 deletions
10
tests/functional/lang/eval-fail-genericClosure-element-missing-key.err.exp
This file contains hidden or 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,10 @@ | ||
| error: | ||
| … while calling the 'genericClosure' builtin | ||
| at /pwd/lang/eval-fail-genericClosure-element-missing-key.nix:1:1: | ||
| 1| builtins.genericClosure { | ||
| | ^ | ||
| 2| startSet = [ { nokey = 1; } ]; | ||
|
|
||
| … in genericClosure element { nokey = 1; } | ||
|
|
||
| error: attribute 'key' missing |
4 changes: 4 additions & 0 deletions
4
tests/functional/lang/eval-fail-genericClosure-element-missing-key.nix
This file contains hidden or 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,4 @@ | ||
| builtins.genericClosure { | ||
| startSet = [ { nokey = 1; } ]; | ||
| operator = x: [ ]; | ||
| } |
10 changes: 10 additions & 0 deletions
10
tests/functional/lang/eval-fail-genericClosure-element-not-attrset.err.exp
This file contains hidden or 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,10 @@ | ||
| error: | ||
| … while calling the 'genericClosure' builtin | ||
| at /pwd/lang/eval-fail-genericClosure-element-not-attrset.nix:1:1: | ||
| 1| builtins.genericClosure { | ||
| | ^ | ||
| 2| startSet = [ "not an attrset" ]; | ||
|
|
||
| … in genericClosure element "not an attrset" | ||
|
|
||
| error: expected a set but found a string: "not an attrset" |
4 changes: 4 additions & 0 deletions
4
tests/functional/lang/eval-fail-genericClosure-element-not-attrset.nix
This file contains hidden or 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,4 @@ | ||
| builtins.genericClosure { | ||
| startSet = [ "not an attrset" ]; | ||
| operator = x: [ ]; | ||
| } |
12 changes: 12 additions & 0 deletions
12
tests/functional/lang/eval-fail-genericClosure-keys-incompatible-types.err.exp
This file contains hidden or 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,12 @@ | ||
| error: | ||
| … while calling the 'genericClosure' builtin | ||
| at /pwd/lang/eval-fail-genericClosure-keys-incompatible-types.nix:1:1: | ||
| 1| builtins.genericClosure { | ||
| | ^ | ||
| 2| startSet = [ | ||
|
|
||
| … while comparing element { key = "string"; } | ||
|
|
||
| … with element { key = 1; } | ||
|
|
||
| error: cannot compare a string with an integer; values are "string" and 1 |
7 changes: 7 additions & 0 deletions
7
tests/functional/lang/eval-fail-genericClosure-keys-incompatible-types.nix
This file contains hidden or 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,7 @@ | ||
| builtins.genericClosure { | ||
| startSet = [ | ||
| { key = 1; } | ||
| { key = "string"; } | ||
| ]; | ||
| operator = x: [ ]; | ||
| } |
12 changes: 12 additions & 0 deletions
12
tests/functional/lang/eval-fail-genericClosure-keys-uncomparable.err.exp
This file contains hidden or 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,12 @@ | ||
| error: | ||
| … while calling the 'genericClosure' builtin | ||
| at /pwd/lang/eval-fail-genericClosure-keys-uncomparable.nix:1:1: | ||
| 1| builtins.genericClosure { | ||
| | ^ | ||
| 2| startSet = [ | ||
|
|
||
| … while comparing element { key = { }; } | ||
|
|
||
| … with element { key = { }; } | ||
|
|
||
| error: cannot compare a set with a set; values of that type are incomparable (values are { } and { }) |
7 changes: 7 additions & 0 deletions
7
tests/functional/lang/eval-fail-genericClosure-keys-uncomparable.nix
This file contains hidden or 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,7 @@ | ||
| builtins.genericClosure { | ||
| startSet = [ | ||
| { key = { }; } | ||
| { key = { }; } | ||
| ]; | ||
| operator = x: [ ]; | ||
| } |
10 changes: 10 additions & 0 deletions
10
tests/functional/lang/eval-fail-genericClosure-missing-operator.err.exp
This file contains hidden or 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,10 @@ | ||
| error: | ||
| … while calling the 'genericClosure' builtin | ||
| at /pwd/lang/eval-fail-genericClosure-missing-operator.nix:1:1: | ||
| 1| builtins.genericClosure { | ||
| | ^ | ||
| 2| startSet = [ { key = 1; } ]; | ||
|
|
||
| … in the attrset passed as argument to builtins.genericClosure | ||
|
|
||
| error: attribute 'operator' missing |
3 changes: 3 additions & 0 deletions
3
tests/functional/lang/eval-fail-genericClosure-missing-operator.nix
This file contains hidden or 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,3 @@ | ||
| builtins.genericClosure { | ||
| startSet = [ { key = 1; } ]; | ||
| } |
10 changes: 10 additions & 0 deletions
10
tests/functional/lang/eval-fail-genericClosure-missing-startSet.err.exp
This file contains hidden or 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,10 @@ | ||
| error: | ||
| … while calling the 'genericClosure' builtin | ||
| at /pwd/lang/eval-fail-genericClosure-missing-startSet.nix:1:1: | ||
| 1| builtins.genericClosure { | ||
| | ^ | ||
| 2| operator = x: [ ]; | ||
|
|
||
| … in the attrset passed as argument to builtins.genericClosure | ||
|
|
||
| error: attribute 'startSet' missing |
3 changes: 3 additions & 0 deletions
3
tests/functional/lang/eval-fail-genericClosure-missing-startSet.nix
This file contains hidden or 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,3 @@ | ||
| builtins.genericClosure { | ||
| operator = x: [ ]; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW I did add
HasSubstrIgnoreANSIMatcherfor similar cases so that one doesn't have to worry about exact colors in unit tests. That could alleviate some of the issues.(Posting this primarily for visibility. I've been using that utility in unit tests where I needed to validate error messages in a somewhat concise manner)
But yeah, it's not worth keeping these tests considering how low-value and fragile they are.