3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/lib/tests
Maximilian Bosch 7203788068
lib/generators: withRecursion: don't break attr-sets with special attrs
Closes #168327

The issue reported there can be demonstrated with the following
expression:

    → nix-instantiate --eval -E "with import ./. {}; pkgs.lib.options.showDefs [ { file = \"foo\"; value = pkgs.rust.packages.stable.buildRustPackages; } ]"
    error: attempt to call something which is not a function but a string

           at /home/ma27/Projects/nixpkgs/lib/trivial.nix:442:35:

              441|   isFunction = f: builtins.isFunction f ||
              442|     (f ? __functor && isFunction (f.__functor f));
                 |                                   ^
              443|

Basically, if a `__functor` is in an attribute-set at depth-limit,
`__functor` will be set to `"<unevaluated>"`. This however breaks
`lib.isFunction` which checks for a `__functor` by invoking `__functor`
with `f` itself.

The same issue - "magic" attributes being shadowed by `withRecursion` -
also applies to others such as
`__pretty`/`__functionArgs`/`__toString`.

Since these attributes have a low-risk of causing a stack overflow
(because these are flat attr-sets or even functions), ignoring them in
`withRecursion` seems like a valid solution.
2022-04-12 12:34:23 +02:00
..
modules Merge pull request #156533 from hercules-ci/issue-146882-transparent-submodule-options 2022-03-16 21:44:35 +01:00
check-eval.nix
maintainers.nix
misc.nix lib/generators: withRecursion: don't break attr-sets with special attrs 2022-04-12 12:34:23 +02:00
modules.sh Merge pull request #156533 from hercules-ci/issue-146882-transparent-submodule-options 2022-03-16 21:44:35 +01:00
release.nix lib/tests/sources: update to Nix 2.4 cli syntax 2021-11-09 10:47:20 -08:00
sources.sh lib/tests: Set hardening pragmas 2021-11-26 10:55:14 +13:00
systems.nix lib/systems: add mips64el definitions 2022-03-10 20:30:16 -08:00