oxalica / nil

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

Warn about unused non-record function arguments #55

Closed poscat0x04 closed 1 year ago

poscat0x04 commented 1 year ago

Proposed feature

Add a warning for simple (non-record, i.e., not of the form { xxx }) function arguments that

  1. Does not have underscore (_) preceding its name
  2. Not used in the function body

For example, the following code will have this warning (on the variable y).

x: y: x

While this code

x: _: x

or this code

x: _y: x

will not.

oxalica commented 1 year ago

Add a warning for simple (non-record, i.e., not of the form { xxx }) function arguments that

1. Does not have underscore (`_`) preceding its name

2. Not used in the function body

_ starting identifiers are now ignored from liveness check. Note that { a }: 42 will still not trigger a warning since it's different from _: 42: the former requires the argument to be in the given form, or it will throw even without evaluating it.