summaryrefslogtreecommitdiff
path: root/testsuite/tests/dependent/should_fail/T15215.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2018-06-15 09:46:30 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2018-06-15 09:47:41 +0100
commit2f6069ccf21d7be0e09016896238f417d2492ffa (patch)
tree937dde091434ea52e47d279483eab6b77bda4099 /testsuite/tests/dependent/should_fail/T15215.hs
parentf903e5510d4562fddef1d4140971e2b93a45e45e (diff)
downloadhaskell-2f6069ccf21d7be0e09016896238f417d2492ffa.tar.gz
Make better "fake tycons" in error recovery
Consider (Trac #15215) data T a = MkT ... data S a = ...T...MkT.... If there is an error in the definition of 'T' we add a "fake type constructor" to the type environment, so that we can continue to typecheck 'S'. But we /were not/ adding a fake anything for 'MkT' and so there was an internal error when we met 'MkT' in the body of 'S'. The fix is to add fake tycons for all the 'implicits' of 'T'. This is done by mk_fake_tc in TcTyClsDecls.checkValidTyCl, which now returns a /list/ of TyCons rather than just one. On the way I did some refactoring: * Rename TcTyDecls.tcAddImplicits to tcAddTyConsToGblEnv and make it /include/ the TyCons themeselves as well as their implicits * Some incidental refactoring about tcRecSelBinds. The main thing is that I've avoided creating a HsValBinds that we immediately decompose. That meant moving some deck chairs around. NB: The new error message for the regression test T15215 has the opaque error "Illegal constraint in a type:", flagged in Trac #14845. But that's the fault of the latter ticket. The fix here not to blame.
Diffstat (limited to 'testsuite/tests/dependent/should_fail/T15215.hs')
-rw-r--r--testsuite/tests/dependent/should_fail/T15215.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/testsuite/tests/dependent/should_fail/T15215.hs b/testsuite/tests/dependent/should_fail/T15215.hs
new file mode 100644
index 0000000000..96fe04385b
--- /dev/null
+++ b/testsuite/tests/dependent/should_fail/T15215.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE GADTs #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeInType #-}
+module T15215 where
+
+import Data.Kind
+
+data A :: Type -> Type where
+ MkA :: Show (Maybe a) => A a
+
+data SA :: forall a. A a -> Type where
+ SMkA :: SA MkA