Skip to content

Repl-formatting: attributeValue lazyness changed by {removeAttrs,mapAttrs,intersectAttrs, ... } #14414

@hsjobeki

Description

@hsjobeki

Describe the bug

The repl formatting is eagerly evaluating attribute values

But only if the attribute set was passed through removeAttrs. ( and so on)

This is particularly annoying because nixpkgs module system has the following line:

config = checked (removeAttrs declaredConfig [ "_module" ]);

And that triggers all otherwise lazy module system errors to be shown in the repl.

  • We don't want to show them all at once, only when accessing the attribute.
  • The output gives the false sense, that the value is an Error while the actual Error is further down

Steps To Reproduce

nix-repl> orig = { foo = throw "Error"; a = 1; }

nix-repl> orig
{
  a = 1;
  foo = «error: Error»;
}

nix-repl> res = builtins.removeAttrs orig ["a"]

nix-repl> res
error:
       … while calling the 'throw' builtin
         at «string»:1:31:
            1|  builtins.removeAttrs { foo = throw "Error"; a = 1; } ["a"]
             |                               ^

       error: Error
{

Expected behavior

Formatting shouldn't get affected by removeAttrs or any other primops.

Metadata

Confirmed on:
nix-env (Nix) 2.30.2
nix-env (Nix) 2.28.5

Additional context

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugreplThe Read Eval Print Loop, "nix repl" command and debugger

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions