Lints and suggestions for the Nix programming language
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

make eta_reduction less aggressive (#76)

Co-authored-by: Stephan Maka <stephan.maka@cyberus-technology.de>

authored by

Astro
Stephan Maka
and committed by
GitHub
bcb3d10f 3c7136a2

+7 -1
+3
bin/tests/data/eta_reduction.nix
··· 15 15 16 16 # other non-free forms 17 17 (map (f: {inherit f;}.double f.val) [ f ]) 18 + 19 + # don't reduce on more complex lambda bodies 20 + (map (x: builtins.div 3 x) xs) 18 21 ]
+4 -1
lib/src/lints/eta_reduction.rs
··· 56 56 if let Some(value_node) = body.value(); 57 57 if let Some(value) = Ident::cast(value_node); 58 58 59 - if arg.as_str() == value.as_str() ; 59 + if arg.as_str() == value.as_str(); 60 60 61 61 if let Some(lambda_node) = body.lambda(); 62 62 if !mentions_ident(&arg, &lambda_node); 63 + // lambda body should be no more than a single Ident to 64 + // retain code readability 65 + if let Some(_) = Ident::cast(lambda_node); 63 66 64 67 then { 65 68 let at = node.text_range();