diff options
| author | Silvan Mosberger <contact@infinisil.com> | 2021-08-04 00:47:59 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-04 00:47:59 +0200 |
| commit | 6745921e23ce778dd686bfdffe5417c990709ded (patch) | |
| tree | 55ec2b2bffa4f7d693b23c49dab337fb481ffc71 | |
| parent | Merge pull request #131938 from chuahou/update-flameshot-backport-21.05 (diff) | |
| parent | lib: fix functionArgs for functors (diff) | |
| download | nixpkgs-6745921e23ce778dd686bfdffe5417c990709ded.tar.gz | |
Merge pull request #132602 from NixOS/backport-131267-to-release-21.05
[Backport release-21.05] lib: fix functionArgs for functors
| -rw-r--r-- | lib/tests/misc.nix | 10 | ||||
| -rw-r--r-- | lib/trivial.nix | 5 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index 0d249968402d..4b2e5afc1d60 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -132,6 +132,16 @@ runTests { expected = [ 1 1 0 ]; }; + testFunctionArgsFunctor = { + expr = functionArgs { __functor = self: { a, b }: null; }; + expected = { a = false; b = false; }; + }; + + testFunctionArgsSetFunctionArgs = { + expr = functionArgs (setFunctionArgs (args: args.x) { x = false; }); + expected = { x = false; }; + }; + # STRINGS testConcatMapStrings = { diff --git a/lib/trivial.nix b/lib/trivial.nix index f6f5da5998ff..48a1b128e2e2 100644 --- a/lib/trivial.nix +++ b/lib/trivial.nix @@ -334,7 +334,10 @@ rec { has the same return type and semantics as builtins.functionArgs. setFunctionArgs : (a → b) → Map String Bool. */ - functionArgs = f: f.__functionArgs or (builtins.functionArgs f); + functionArgs = f: + if f ? __functor + then f.__functionArgs or (lib.functionArgs (f.__functor f)) + else builtins.functionArgs f; /* Check whether something is a function or something annotated with function args. |
