COMPLETE sets nerf redundant pattern-match warnings
If I give redundant patterns for a datatype with a COMPLETE
set, then GHC doesn't warn me at all. Here's an example:
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ViewPatterns #-}
module Bug (Boolean(F, TooGoodToBeTrue), catchAll) where
data Boolean = F | T
deriving Eq
pattern TooGoodToBeTrue :: Boolean
pattern TooGoodToBeTrue <- ((== T) -> True)
where
TooGoodToBeTrue = T
{-# COMPLETE F, TooGoodToBeTrue #-}
catchAll :: Boolean -> Int
catchAll F = 0
catchAll TooGoodToBeTrue = 1
catchAll F = 2
GHC thinks this is fine and dandy:
$ /opt/ghc/8.2.1/bin/ghci Bug.hs -Wall
GHCi, version 8.2.0.20170704: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Ok, 1 module loaded.
This problem also persists across modules:
module Foo where
import Bug
catchAll2 :: Boolean -> Int
catchAll2 F = 0
catchAll2 TooGoodToBeTrue = 1
catchAll2 F = 2
$ /opt/ghc/8.2.1/bin/ghci Foo.hs -Wall
GHCi, version 8.2.0.20170704: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 2] Compiling Bug ( Bug.hs, interpreted )
[2 of 2] Compiling Foo ( Foo.hs, interpreted )
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.1-rc2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |