astro / deadnix

Scan Nix files for dead code
GNU General Public License v3.0
445 stars 15 forks source link

[Bug?]: Lambda arguments starting with underscore are always allowed #78

Open sivizius opened 2 months ago

sivizius commented 2 months ago

Due to https://github.com/astro/deadnix/blob/main/src/scope.rs#L105, lambda arguments starting with _ are always allowed, even without --no-underscore. This behaviour is different from other bindings, e.g. let _foo = 23; in …, where --no-underscore is necessary, and thus unexpected. I suggest to either change this to name.syntax().text() != "_" or remove this flag and always allow symbols starting with _, even in let-bindings, which is the default in many programming languages including rust.

astro commented 2 months ago

I agree that this behavior seems inconsistent.

The LambdaArg case however is a bit special because it cannot be removed entirely. Renaming them to _ makes code less self-explanatory. I'd like to reconsider about that for a few days.

Against the alternative proposal, I think finding dead declarations that start with _ is very useful.