FSharpLint icon indicating copy to clipboard operation
FSharpLint copied to clipboard

Add warnings for partial functions

Open Krzysztof-Cieslak opened this issue 7 years ago • 2 comments

Add warnings for partial functions such as List.head or Option.get

Krzysztof-Cieslak avatar Jul 20 '17 21:07 Krzysztof-Cieslak

I think this is a good addition, in my experience a lot of bugs can arise through using partial functions, and in most cases you shouldn't be using them when writing idiomatic F#.

My initial thought was that this could be achieved by adding hints, and it can to some degree, but with a dedicated rule we could also make use of typechecking information to check for instances of optionVar.Value and similar usages.

jgardella avatar Jun 08 '20 19:06 jgardella

It would be quite cool if the hints allow you to specify the type of a variable, that would enable this to be done via hints and enable other rules like unnecessary casts etc to be done via hints

duckmatt avatar Jun 10 '20 19:06 duckmatt