diff options
Diffstat (limited to 'testsuite/tests/patsyn/should_fail/T11667.hs')
-rw-r--r-- | testsuite/tests/patsyn/should_fail/T11667.hs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/testsuite/tests/patsyn/should_fail/T11667.hs b/testsuite/tests/patsyn/should_fail/T11667.hs new file mode 100644 index 0000000000..f2437fa8c5 --- /dev/null +++ b/testsuite/tests/patsyn/should_fail/T11667.hs @@ -0,0 +1,31 @@ +{-# LANGUAGE PatternSynonyms, GADTs #-} +module T11667 where + +{- +The following four pattern synonym declarations should give valid +error messages +-} + +-- Check if we mention no explicit type signature (or the correct +-- signature "Eq a => Maybe a") +pattern Pat1 :: Eq a => Maybe a +pattern Pat1 <- Just 42 + +-- Check if we mention no explicit type signature (or the correct +-- signature "forall b. () => forall a. b ~ Bool => a -> b -> (b, T)") +data T where MkT :: a -> T +pattern Pat2 :: () => b ~ Bool => a -> b -> (b, T) +pattern Pat2 x y = (y, MkT x) + +-- Check if we do not tell the user that we could not deduce (Show a) +-- from the "required" context. Also, check if we do not give the +-- possible fix that suggests to add (Show a) to the "required" context. +pattern Pat3 :: Eq a => Show a => a -> Maybe a +pattern Pat3 x <- Just x + +-- Check if we return a valid error message concerning the missing +-- constraint (Num a) when the bidirectional pattern synonym is used +-- in an expression context +data S a where MkS :: (Num a, Show a) => a -> S a +pattern Pat4 :: (Eq a) => (Show a) => S a +pattern Pat4 = MkS 42 |