New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow specifying a recursionLimit
for toPretty
#98477
Conversation
This allows easily controlling how deep it recurses into structures
The error trace shows like this: $ nix-instantiate --eval -E 'with import ./lib; generators.toPretty {} { x.y = [ (throw "nope") ]; }' --show-trace
error: while evaluating 'go' at /home/infinisil/src/nixpkgs/lib/generators.nix:211:17, called from (string):1:20:
while evaluating anonymous function at /home/infinisil/src/nixpkgs/lib/attrsets.nix:234:10, called from undefined position:
while evaluating anonymous function at /home/infinisil/src/nixpkgs/lib/generators.nix:262:22, called from /home/infinisil/src/nixpkgs/lib/attrsets.nix:234:16:
while lib.generators.toPretty descended into the `x' attribute
while evaluating 'go' at /home/infinisil/src/nixpkgs/lib/generators.nix:211:17, called from /home/infinisil/src/nixpkgs/lib/generators.nix:264:57:
while evaluating anonymous function at /home/infinisil/src/nixpkgs/lib/attrsets.nix:234:10, called from undefined position:
while evaluating anonymous function at /home/infinisil/src/nixpkgs/lib/generators.nix:262:22, called from /home/infinisil/src/nixpkgs/lib/attrsets.nix:234:16:
while lib.generators.toPretty descended into the `y' attribute
while evaluating 'go' at /home/infinisil/src/nixpkgs/lib/generators.nix:211:17, called from /home/infinisil/src/nixpkgs/lib/generators.nix:264:57:
while evaluating anonymous function at /home/infinisil/src/nixpkgs/lib/lists.nix:106:29, called from undefined position:
while evaluating anonymous function at /home/infinisil/src/nixpkgs/lib/generators.nix:240:61, called from /home/infinisil/src/nixpkgs/lib/lists.nix:106:32:
while lib.generators.toPretty descended into list index `0'
while evaluating 'go' at /home/infinisil/src/nixpkgs/lib/generators.nix:211:17, called from /home/infinisil/src/nixpkgs/lib/generators.nix:242:14:
nope |
I’m getting a bit worried that |
Like, the |
Closing this for now as I have other changes relating to this |
Now #98761 adds the |
Motivation for this change
For being able to print infinitely-recursing values in #98155
Also,
toPretty
now adds relevant error context when recursingSee also #97133 which did other
toPretty
improvementsPing @Profpatsch
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)