From 87091539739e8ee30217e6483a8b13b27f5bc31e Mon Sep 17 00:00:00 2001 From: sterni Date: Sun, 31 Jan 2021 19:36:46 +0100 Subject: fix(tvix/libexpr): backport fix for functionArgs failing on primops Nix internally differentiates between lambdas and primops, but their type in the nix expression language is the same (lambda). The implementation of builtins.functionArgs only checks if the given expression is of type tLambda and fails if the type is tPrimop or tPrimopApp which are also functions. This most notably breaks lib.generators.toPretty when called on a builtin making for example yants fail if a primop is typechecked and an error message is generated. This fix generates an empty set for primops like for plain lambdas and is based upstream commit b2748c6e99239ff6803ba0da76c362790c8be192. Additionally we add to two tests: * eval-okay-functionargs now includes a few test cases checking that builtins.functionArgs always returns an empty set for builtins and also works as expected for normal functions. * eval-okay-types now also checks if builtins are functions. Future work would be to make builtins.functionArgs work as users would expect for builtins like builtins.fetchurl, builtins.fetchGit etc. which take a set as an argument. These currently don't register as formal arguments, but it would be an usability improvement at least if they did. See also https://github.com/NixOS/nix/pull/3626#issuecomment-698546704 Change-Id: I2bf4cb80d44a4b72ade13d3e0dbd7dfb1d049f32 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2477 Tested-by: BuildkiteCI Reviewed-by: Profpatsch Reviewed-by: glittershark --- third_party/nix/src/tests/lang/eval-okay-types.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'third_party/nix/src/tests/lang/eval-okay-types.nix') diff --git a/third_party/nix/src/tests/lang/eval-okay-types.nix b/third_party/nix/src/tests/lang/eval-okay-types.nix index 9b58be5d1d..cc51d8cb7a 100644 --- a/third_party/nix/src/tests/lang/eval-okay-types.nix +++ b/third_party/nix/src/tests/lang/eval-okay-types.nix @@ -3,6 +3,7 @@ with builtins; [ (isNull null) (isNull (x: x)) (isFunction (x: x)) + (isFunction functionArgs) (isFunction "fnord") (isString ("foo" + "bar")) (isString [ "x" ]) -- cgit 1.4.1