oppiliappan / statix

lints and suggestions for the nix programming language
https://git.peppe.rs/languages/statix/about
MIT License
552 stars 21 forks source link

false positive for useless_parens with a value called `or` #39

Open maralorn opened 2 years ago

maralorn commented 2 years ago

I have a fun one. A situation where the useless_parens lint is triggered, although removing the parentheses changes the semantics.

Consider

(builtins.foldl') or "false" list_of_something_boolish

where or is a not a keyword but a regular function from my code. This is not equivalent to

builtins.foldl' or "false" list_of_something_boolish

where or is part of the . operator. (compare first entry in this list: https://nixos.org/manual/nix/stable/expressions/language-operators.html)

I admit this is a bit esoteric, but this was the easiest way not have the or interpreted as the operator and the false positive warning happened to me without searching for it.