NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.14k stars 1.47k forks source link

Nix expression language warnings #1364

Open copumpkin opened 7 years ago

copumpkin commented 7 years ago

It'd be nice if I could opt into warnings, like I can with many compilers (e.g., -Wall, -Werror, etc. in C compilers).

The most obvious warning that comes to mind would look something like this:

warning: suspicious shadowing between `with` binding for <varname> and external context at <loc>

That would indicate if you have a with binding in scope while also having the same binding from the outer scope. I'm sure there are a few other "likely programmer errors" we could catch this way.

Another implementation could be to have a nix lint subcommand in the new UI, but I'm afraid of branching the expression language handling too much from the actual evaluation of the language, so it seems like it would need to be integrated into libexpr somehow.

Related to #1361.

thufschmitt commented 7 years ago

Having static warnings would probably be quite hard[1] because the language is too dynamic, but having an evaluation mode where those warnings are thrown at runtime should be easier, and already really nice.

[1]: although some errors could probably be caught by the type-checker I'm writing

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info