Truncated stack traces obscure the actual problem when interpolating numbers into strings #820

Open
opened 2025-05-05 18:55:51 +00:00 by jade · 1 comment
Owner
let
  pkgs = import <nixpkgs> {};
in
  pkgs.lib.genAttrs (pkgs.lib.genList (x: "${x}") 5) (x: x)

Actual:

$ nix eval -f bad-error.nix
error:
       … while evaluating the file '/Users/jade/lix/lix2/bad-error.nix':

       … while calling the 'listToAttrs' builtin
         at /nix/store/jixf9nqph68dh1il92w6j4l0h0fgwdvz-source/lib/attrsets.nix:1219:24:
         1218|   */
         1219|   genAttrs = names: f: listToAttrs (map (n: nameValuePair n (f n)) names);
             |                        ^
         1220|

       … while evaluating the `name` attribute of an element of the list passed to builtins.listToAttrs
         at /nix/store/jixf9nqph68dh1il92w6j4l0h0fgwdvz-source/lib/attrsets.nix:977:42:
          976|   */
          977|   nameValuePair = name: value: { inherit name value; };
             |                                          ^
          978|

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: cannot coerce an integer to a string: 0

Expected: Something pointing to the actual interpolation at fault. It seems that this is because of our stack trace truncator though: it shows up in the --show-trace:

       … while calling anonymous lambda
         at /Users/jade/lix/lix2/bad-error.nix:4:40:
            3| in
            4|   pkgs.lib.genAttrs (pkgs.lib.genList (x: "${x}") 5) (x: x)
             |                                        ^
            5|

       … while evaluating a path segment
         at /Users/jade/lix/lix2/bad-error.nix:4:44:
            3| in
            4|   pkgs.lib.genAttrs (pkgs.lib.genList (x: "${x}") 5) (x: x)
             |                                            ^
            5|

       error: cannot coerce an integer to a string: 0

This is on dad17a54f7

```nix let pkgs = import <nixpkgs> {}; in pkgs.lib.genAttrs (pkgs.lib.genList (x: "${x}") 5) (x: x) ``` Actual: ``` $ nix eval -f bad-error.nix error: … while evaluating the file '/Users/jade/lix/lix2/bad-error.nix': … while calling the 'listToAttrs' builtin at /nix/store/jixf9nqph68dh1il92w6j4l0h0fgwdvz-source/lib/attrsets.nix:1219:24: 1218| */ 1219| genAttrs = names: f: listToAttrs (map (n: nameValuePair n (f n)) names); | ^ 1220| … while evaluating the `name` attribute of an element of the list passed to builtins.listToAttrs at /nix/store/jixf9nqph68dh1il92w6j4l0h0fgwdvz-source/lib/attrsets.nix:977:42: 976| */ 977| nameValuePair = name: value: { inherit name value; }; | ^ 978| (stack trace truncated; use '--show-trace' to show the full trace) error: cannot coerce an integer to a string: 0 ``` Expected: Something pointing to the actual interpolation at fault. It seems that this is because of our stack trace truncator though: it shows up in the --show-trace: ``` … while calling anonymous lambda at /Users/jade/lix/lix2/bad-error.nix:4:40: 3| in 4| pkgs.lib.genAttrs (pkgs.lib.genList (x: "${x}") 5) (x: x) | ^ 5| … while evaluating a path segment at /Users/jade/lix/lix2/bad-error.nix:4:44: 3| in 4| pkgs.lib.genAttrs (pkgs.lib.genList (x: "${x}") 5) (x: x) | ^ 5| error: cannot coerce an integer to a string: 0 ``` This is on dad17a54f7cf2bae24274dc2b9a535c1938e6eb0
jade added this to the Error reporting project 2025-05-05 18:55:51 +00:00
Owner

duplicate of #808?

duplicate of #808?
Sign in to join this conversation.
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#820
No description provided.