Header menu logo ionide-analyzers

HeadConsEmptyListPatternAnalyzer

Problem

Using the cons pattern (::) with an empty list does not make much sense.

match [] with
// Triggers analyzer
| x :: [] -> ()
| _ -> ()

Fix

Check for a pattern with a single item in the list instead.

match [] with
| [ x ] -> ()
| _ -> ()

Code fix

This analyzer has a code fix for Ionide:

Code fix for HeadConsEmptyListPattern

val x: obj

Type something to start searching.