navigation

FavourAsKeyword (FL0086)

Introduced in 0.24.3

Cause

A named pattern is used just to be compared in the guard against a constant expression e.g. match something with | bar when bar = "baz" -> ()

Rationale

The named pattern can be changed to an as pattern that uses a constant pattern, improving the pattern matching exhaustiveness check

How To Fix

Remove the guard and replace the named pattern with the as pattern using a constant pattern, e.g. change match something with | bar when bar = "baz" -> () to match something with | "baz" as bar -> ()

Rule Settings

{
    "favourAsKeyword": {
        "enabled": true
    }
}