Missing field(s) [GHC-20125]

Flag: -Wmissing-fields
Enabled by default

When constructing a record using labeled fields, all fields which are not explicitly stated are implicitly initialized with a bottom term. This means that accessing the field results in a panic.

If a strict field is missing, the error GHC-95909 is emitted instead.

Examples

Uninitialized record field

The field c of the record Rec is not initialized.

Error Message

GHC-20125/example1/before/Error.hs:7:5: warning: [-Wmissing-fields] [GHC-20125]
    • Fields of ‘Rec’ not initialised:
        c :: Bool
    • In the expression: Rec {a = 1, b = "two"}
      In an equation for ‘x’: x = Rec {a = 1, b = "two"}
  |
7 | x = Rec { a = 1, b = "two" }
Error.hs
Before
{-# OPTIONS_GHC -Wmissing-fields #-}
module Error where

data Rec = Rec { a :: Int, b :: String, c :: Bool }

x :: Rec
x = Rec { a = 1, b = "two" }
After
{-# OPTIONS_GHC -Wmissing-fields #-}
module Error where

data Rec = Rec { a :: Int, b :: String, c :: Bool }

x :: Rec
x = Rec { a = 1, b = "two", c = True }