Incorrect incomplete pattern warning with GADTs and classes
Here is the test case:
{-# LANGUAGE DataKinds, KindSignatures, GADTs, ScopedTypeVariables,
TypeApplications, AllowAmbiguousTypes #-}
{-# OPTIONS_GHC -Wincomplete-patterns #-}
module Bug where
import Data.Kind
data SBool :: Bool -> Type where
SFalse :: SBool False
STrue :: SBool True
class IBool b where
bool :: SBool b
instance IBool False where
bool = SFalse
instance IBool True where
bool = STrue
foo :: forall b. IBool b => SBool b -> ()
foo _sb = case bool @b of
STrue -> ()
SFalse -> ()
I get
Bug.hs:23:11: warning: [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In a case alternative:
Patterns not matched: _ :: IBool b => SBool b
|
23 | foo _sb = case bool @b of
| ^^^^^^^^^^^^
But I'm pretty sure my pattern match is complete there. The class seems necessary: if I just use _sb
as the scrutinee, all is well.