Skip to content

Warnings from -fwarn-incomplete-record-updates even with all constructors matched

I don't think that the following should be considered an incomplete record update, since I match on the other constructor before the record update:

data Foo = None | Bar { baz :: Int }

quux :: Foo -> Foo
quux None = None
quux x = x { baz = 2 }

main :: IO ()
main = return ()

But it still throws a warning:

$ ghc -fwarn-incomplete-record-updates test.hs
[1 of 1] Compiling Main             ( test.hs, test.o )

test.hs:6:10:
    Warning: Pattern match(es) are non-exhaustive
             In a record-update construct: Patterns not matched: None
Linking test ...
Trac metadata
Trac field Value
Version 7.2.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information