summaryrefslogtreecommitdiff
path: root/testsuite/tests/backpack/should_fail/bkpfail54.bkp
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2023-05-15 15:23:49 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-05-15 18:03:00 -0400
commit4d29ecdfcc79ad663e066d9f7d6d17b64c8c6c41 (patch)
tree985890c63aee54a2e94e31aa85cbec44652987b9 /testsuite/tests/backpack/should_fail/bkpfail54.bkp
parentd69cbd78999071d2d6479be40ae90ddd83b9942a (diff)
downloadhaskell-4d29ecdfcc79ad663e066d9f7d6d17b64c8c6c41.tar.gz
Migrate errors to diagnostics in GHC.Tc.Module
This commit migrates the errors in GHC.Tc.Module to use the new diagnostic infrastructure. It required a significant overhaul of the compatibility checks between an hs-boot or signature module and its implementation; we now use a Writer monad to accumulate errors; see the BootMismatch datatype in GHC.Tc.Errors.Types, with its panoply of subtypes. For the sake of readability, several local functions inside the 'checkBootTyCon' function were split off into top-level functions. We split off GHC.Types.HscSource into a "boot or sig" vs "normal hs file" datatype, as this mirrors the logic in several other places where we want to treat hs-boot and hsig files in a similar fashion. This commit also refactors the Backpack checks for type synonyms implementing abstract data, to correctly reject implementations that contain qualified or quantified types (this fixes #23342 and #23344).
Diffstat (limited to 'testsuite/tests/backpack/should_fail/bkpfail54.bkp')
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail54.bkp47
1 files changed, 47 insertions, 0 deletions
diff --git a/testsuite/tests/backpack/should_fail/bkpfail54.bkp b/testsuite/tests/backpack/should_fail/bkpfail54.bkp
new file mode 100644
index 0000000000..4248390c91
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail54.bkp
@@ -0,0 +1,47 @@
+
+-- Check that we do something sensible when we implement
+-- abstract data with a quantified type.
+
+{-# LANGUAGE StandaloneKindSignatures #-}
+{-# LANGUAGE TypeFamilies #-}
+
+unit p where
+ module M where
+ import Data.Kind ( Type, Constraint )
+
+ type C :: Type -> Constraint
+ class C a where
+ type family F a :: Type
+
+unit q where
+ dependency p
+ signature H where
+ data T1
+ data T2
+ data T3
+ module N where
+ import M ( C(F) )
+ import H ( T1, T2, T3 )
+
+ instance C T1 where
+ type F T1 = T2
+ instance C T2 where
+ type F T2 = T3
+ instance C T3 where
+ type F T3 = T1
+
+unit r where
+ dependency p
+ module H where
+
+ class C2 a where {}
+ data S = MkS
+
+ type T1 = forall a. a -> a
+ type T2 = forall a. C2 a => a
+ type T3 = C2 S => S -> S
+
+unit s where
+ dependency p
+ dependency r
+ dependency q[H=r:H]