False positives from -Wincomplete-record-updates
Summary
GHC will issue -Wincomplete-record-updates warnings even when the record update is guaranteed to succeed.
Steps to reproduce
Compile this code:
{-# OPTIONS -Wincomplete-record-updates #-}
data FooBar = Foo { w :: Int, x :: Char, y :: Float, z :: String } | Bar
f :: FooBar -> FooBar
f foo@Foo{} = foo{ w = 42 }
f Bar = Bar
Expected behavior
Since I specified foo@Foo{}
, GHC should realize that foo
must be a Foo
and so not warn me that it could be a Bar
.
Environment
- GHC version used: 8.10.2
Optional:
- Operating System: Linux
- System Architecture: x86_64