Incomplete record selector application [GHC-17335]

Flag: -Wincomplete-record-selectors
Enabled by:

This warning is triggered when GHC is not certain whether a record selector application will be successful. This happens when a record selector is not defined for all constructors of a data type (a.k.a. partial record field selector) and it is applied to a value whose data constructor can’t be proved by GHC to be one for which the selector is defined.

Examples

Incomplete record selector application
DsIncompleteRecSel.hs
Before
module DsIncompleteRecSel where

data T = T1 | T2 {x :: Bool}

f :: T -> Bool
f a = x a
After
module DsIncompleteRecSel where

data T = T1 | T2 {x :: Bool}

f :: T -> Bool
f T1 = True -- handle the T1 case
f a = x a