oxalica / nil

NIx Language server, an incremental analysis assistant for writing in Nix.
Apache License 2.0
1.38k stars 40 forks source link

inappropriate unused_binding diagnostic with named attribute set argument (@) #73

Closed edrex closed 1 year ago

edrex commented 1 year ago

This is a general issue, but the common use-case where I'm hitting it is in a flake when utilizing the registry to avoid specifying an explicit input URL:

screenshot-20230412-180511

inputs.nixos-hardware is not used directly in the function body, but in an expression in an included file which is passed inputs (same for home-manager and helix (src). Basically, since nil doesn't analyze into included files, it should be enough if the named attribute set argument (here, inputs) is referenced in the function body. Does that make sense?

Also, thank you so much for working on nil. It has greatly improved my daily experience of working on Nix code, and with each new analysis feature it gets better. :heart:

edrex commented 1 year ago

it should be enough if the named attribute set argument (here, inputs) is referenced in the function body

I should clarify: if the whole attrset is passed into a function, rather than another attr (inputs.bar) being referenced.

edrex commented 1 year ago

... in a flake when utilizing the registry to avoid specifying an explicit input URL

I should also explain, the reason those params are listed is to tell nix to add them as inputs from the registry.

edrex commented 1 year ago

Confirmed fixed with flake inputs. I do feel like this could still be an issue in general with named attrset arguments that get passed into a function defined elsewhere, but I don't have a specific instance in mind so I'm happy with this.