Skip to content

builtins.trace should print lambda location #7145

@roberth

Description

@roberth

Is your feature request related to a problem? Please describe.

There's no reason why trace shouldn't be able to do what the repl printer can:

nix-repl> builtins.trace lib.showOption {}
trace: <LAMBDA>
{ }

nix-repl> lib.showOption
«lambda @ /home/user/h/nixpkgs/lib/options.nix:322:16»

Describe the solution you'd like

At least print the location like the repl does.

More ideas:

  • print closure info when debugger is enabled
  • when the builtins.trace argument is a thunk that points to a string interpolation, copy the thunk and evaluate the string with a flag that allows the lambda to be rendered as a source location (I don't think we have a nice ast node for this though. Add a new method to Expr for this kind of evaluation?)

Describe alternatives you've considered

Use the debugger.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeature request or proposalgood first issueQuick win for first-time contributors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions