Skip to content
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

Attempting to coerce a list to a string may fail with confusing error "cannot coerce a set/function to a string" #97455

Closed
lboklin opened this issue Sep 8, 2020 · 3 comments
Labels
0.kind: bug Something is broken

Comments

@lboklin
Copy link

lboklin commented Sep 8, 2020

Describe the bug

Attempting to call toString on a list containing a set will produce the very confusing error:

cannot coerce a set to a string

or a list containing a function:

cannot coerce a function to a string

This can take a long time to figure out the first time it happens, given that the error focuses on the list, rather than the element in question.

To Reproduce
Steps to reproduce the behavior:

  1. nix eval --expr 'toString [ (x: x) ]' or nix eval --expr 'toString [ {} ]'

Expected behavior
A more helpful error, such as

cannot coerce a list to a string because of one of its elements: cannot coerce a set to a string

Metadata

  • system: "x86_64-linux"
  • host os: Linux 5.7.16, NixOS, 20.09.20200820.c59ea8b (Nightingale)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.4pre20200721_ff314f1
  • channels(root): "nixos-20.03.2806.cb1996818ed"
  • channels(ludvig): "home-manager, nixpkgs-20.09pre238994.078b9f8aa68, nixos-19.09-19.09.2284.bf7c0f0461e"
  • nixpkgs: /home/ludvig/.nix-defexpr/channels/nixpkgs
@lboklin lboklin added the 0.kind: bug Something is broken label Sep 8, 2020
@jonringer
Copy link
Contributor

this should probably be made in https://github.com/NixOS/nix as it relates to the nix cli, and not the nixpkgs package set

@lboklin
Copy link
Author

lboklin commented Sep 8, 2020

this should probably be made in https://github.com/NixOS/nix as it relates to the nix cli, and not the nixpkgs package set

Good point.

@lboklin
Copy link
Author

lboklin commented Sep 8, 2020

Opened at NixOS/nix#4000 instead.

@lboklin lboklin closed this as completed Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

2 participants