mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
Merge pull request #14499 from roberth/genericClosure-errors
`builtins.genericClosure`: improve errors
This commit is contained in:
commit
5a97c00f29
25 changed files with 299 additions and 86 deletions
|
|
@ -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
|
||||
|
|
@ -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) ];
|
||||
}
|
||||
)
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
builtins.genericClosure {
|
||||
startSet = [ { nokey = 1; } ];
|
||||
operator = x: [ ];
|
||||
}
|
||||
|
|
@ -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"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
builtins.genericClosure {
|
||||
startSet = [ "not an attrset" ];
|
||||
operator = x: [ ];
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
builtins.genericClosure {
|
||||
startSet = [
|
||||
{ key = 1; }
|
||||
{ key = "string"; }
|
||||
];
|
||||
operator = x: [ ];
|
||||
}
|
||||
|
|
@ -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 { })
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
builtins.genericClosure {
|
||||
startSet = [
|
||||
{ key = { }; }
|
||||
{ key = { }; }
|
||||
];
|
||||
operator = x: [ ];
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
builtins.genericClosure {
|
||||
startSet = [ { key = 1; } ];
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
builtins.genericClosure {
|
||||
operator = x: [ ];
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
error:
|
||||
… while calling the 'genericClosure' builtin
|
||||
at /pwd/lang/eval-fail-genericClosure-not-attrset.nix:1:1:
|
||||
1| builtins.genericClosure "not an attrset"
|
||||
| ^
|
||||
2|
|
||||
|
||||
… while evaluating the first argument passed to builtins.genericClosure
|
||||
|
||||
error: expected a set but found a string: "not an attrset"
|
||||
|
|
@ -0,0 +1 @@
|
|||
builtins.genericClosure "not an attrset"
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
error:
|
||||
… while calling the 'genericClosure' builtin
|
||||
at /pwd/lang/eval-fail-genericClosure-operator-not-function.nix:1:1:
|
||||
1| builtins.genericClosure {
|
||||
| ^
|
||||
2| startSet = [ { key = 1; } ];
|
||||
|
||||
… while evaluating the 'operator' attribute passed as argument to builtins.genericClosure
|
||||
|
||||
error: expected a function but found a string: "not a function"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
builtins.genericClosure {
|
||||
startSet = [ { key = 1; } ];
|
||||
operator = "not a function";
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
error:
|
||||
… while calling the 'genericClosure' builtin
|
||||
at /pwd/lang/eval-fail-genericClosure-operator-not-list.nix:1:1:
|
||||
1| builtins.genericClosure {
|
||||
| ^
|
||||
2| startSet = [ { key = 1; } ];
|
||||
|
||||
… while calling operator on genericClosure element { key = 1; }
|
||||
|
||||
… while evaluating the return value of the `operator` passed to builtins.genericClosure
|
||||
|
||||
error: expected a list but found a string: "not a list"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
builtins.genericClosure {
|
||||
startSet = [ { key = 1; } ];
|
||||
operator = x: "not a list";
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
error:
|
||||
… while calling the 'genericClosure' builtin
|
||||
at /pwd/lang/eval-fail-genericClosure-startSet-not-list.nix:1:1:
|
||||
1| builtins.genericClosure {
|
||||
| ^
|
||||
2| startSet = "not a list";
|
||||
|
||||
… while evaluating the 'startSet' attribute passed as argument to builtins.genericClosure
|
||||
|
||||
error: expected a list but found a string: "not a list"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
builtins.genericClosure {
|
||||
startSet = "not a list";
|
||||
operator = x: [ ];
|
||||
}
|
||||
4
tests/functional/lang/infinite-nesting.nix
Normal file
4
tests/functional/lang/infinite-nesting.nix
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
let
|
||||
mkInfinite = i: { "a${toString i}" = mkInfinite (i + 1); };
|
||||
in
|
||||
mkInfinite 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue