Status quo: We have `force$Type` and `eval$Type`, both which first produce a value and then do a type check. The type checking logic is not consistently implemented, with lots of code duplication. This change does: - Introduce new `check*` functions which unify the logic (the error handling unfortunately still needs some duplication for now) - Make both `force*` and `eval*` use the `check*` function for the actual type checking - Inline and dismantle the `eval*` functions for being of little use and little used. This makes the `ExprOp*::eval` implementations for binary logic operators more verbose, but IMO that's a good thing: The implementation now needs to be a lot more explicit about the short-circuiting semantics, something which was previously hidden behind the short-circuiting semantics of the C++ language, in a way that could easily be overlooked and lead to confusion, which is something that happened to me twice in a year. - Changes `forceAttrs` and `forceList` to include the context in case `forceValue` fails (compared to only when the type check fails). This was done for code consistency, because I could not find any reason why list and attrs had different semantics here than int, float and bool. So far the visible change is minimal (see the diff on the err.exp), however this needs vetting for potential performance regressions. Change-Id: I33e5c706d46850c9e1126293ee01dab85ba07587
82 lines
2.8 KiB
Plaintext
82 lines
2.8 KiB
Plaintext
error:
|
|
… while calling the 'getAttr' builtin
|
|
at «internal»:1:500:
|
|
… while evaluating the second argument passed to builtins.getAttr
|
|
|
|
… while calling the 'derivationStrict' builtin
|
|
at «internal»:1:208:
|
|
… while evaluating derivation 'package-you-care-about'
|
|
whose name attribute is located at /pwd/in.nix:22:5
|
|
at /pwd/in.nix:22:5:
|
|
21| package-you-care-about = derivation {
|
|
22| name = "package-you-care-about";
|
|
| ^
|
|
23| __structuredAttrs = true;
|
|
|
|
… while evaluating attribute 'buildInputs' of derivation 'package-you-care-about'
|
|
at /pwd/in.nix:25:5:
|
|
24|
|
|
25| buildInputs = [
|
|
| ^
|
|
26| direct-dependency
|
|
|
|
… while evaluating list element at index 0
|
|
|
|
… while calling the 'getAttr' builtin
|
|
at «internal»:1:500:
|
|
… while evaluating the second argument passed to builtins.getAttr
|
|
|
|
… while calling the 'derivationStrict' builtin
|
|
at «internal»:1:208:
|
|
… while evaluating derivation 'direct-dependency'
|
|
whose name attribute is located at /pwd/in.nix:15:5
|
|
at /pwd/in.nix:15:5:
|
|
14| direct-dependency = derivation {
|
|
15| name = "direct-dependency";
|
|
| ^
|
|
16| __structuredAttrs = true;
|
|
|
|
… while evaluating attribute 'libtrans' of derivation 'direct-dependency'
|
|
at /pwd/in.nix:18:5:
|
|
17|
|
|
18| libtrans = transitive-dependency;
|
|
| ^
|
|
19| };
|
|
|
|
… while calling the 'getAttr' builtin
|
|
at «internal»:1:500:
|
|
… while evaluating the second argument passed to builtins.getAttr
|
|
|
|
… while calling the 'derivationStrict' builtin
|
|
at «internal»:1:208:
|
|
… while evaluating derivation 'transitive-dependency'
|
|
whose name attribute is located at /pwd/in.nix:4:5
|
|
at /pwd/in.nix:4:5:
|
|
3| transitive-dependency = mkDerivation {
|
|
4| name = "transitive-dependency";
|
|
| ^
|
|
5| __structuredAttrs = true;
|
|
|
|
… while evaluating attribute 'nativeBuildInputs' of derivation 'transitive-dependency'
|
|
at /pwd/in.nix:7:5:
|
|
6|
|
|
7| nativeBuildInputs = [
|
|
| ^
|
|
8| null
|
|
|
|
… while evaluating list element at index 1
|
|
|
|
… caused by explicit throw
|
|
at /pwd/in.nix:9:8:
|
|
8| null
|
|
9| (throw "transitive dependency growls")
|
|
| ^
|
|
10| ];
|
|
|
|
error: transitive dependency growls
|
|
|
|
note: trace involved the following derivations:
|
|
derivation 'package-you-care-about'
|
|
derivation 'direct-dependency'
|
|
derivation 'transitive-dependency'
|