summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc/Validity.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2021-07-29 11:22:07 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2021-08-15 14:18:52 +0100
commit0f6fb7d309cbe69dcd534c14155d68c981895ab2 (patch)
tree0b3186625410632e0f01a4a07e30b73b9914e222 /compiler/GHC/Tc/Validity.hs
parent71130bf881fefccb4945b7c167d465ba94dda3ec (diff)
downloadhaskell-0f6fb7d309cbe69dcd534c14155d68c981895ab2.tar.gz
TypeError is OK on the RHS of a type synonymwip/T20181
We should not complain about TypeError in type T = TypeError blah This fixes #20181 The error message for T13271 changes, because that test did indeed have a type synonym with TypeError on the RHS
Diffstat (limited to 'compiler/GHC/Tc/Validity.hs')
-rw-r--r--compiler/GHC/Tc/Validity.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/compiler/GHC/Tc/Validity.hs b/compiler/GHC/Tc/Validity.hs
index 3445270c9a..4c141ce082 100644
--- a/compiler/GHC/Tc/Validity.hs
+++ b/compiler/GHC/Tc/Validity.hs
@@ -241,7 +241,7 @@ wantAmbiguityCheck ctxt
StandaloneKindSigCtxt{} -> False
_ -> True
-checkUserTypeError :: Type -> TcM ()
+checkUserTypeError :: UserTypeCtxt -> Type -> TcM ()
-- Check to see if the type signature mentions "TypeError blah"
-- anywhere in it, and fail if so.
--
@@ -250,7 +250,12 @@ checkUserTypeError :: Type -> TcM ()
-- user-supplied one. This is really only a half-baked fix;
-- the other errors in checkValidType don't do tidying, and so
-- may give bad error messages when given an inferred type.
-checkUserTypeError = check
+checkUserTypeError ctxt ty
+ | TySynCtxt {} <- ctxt -- Do not complain about TypeError on the
+ = return () -- RHS of type synonyms. See #20181
+
+ | otherwise
+ = check ty
where
check ty
| Just msg <- userTypeError_maybe ty = fail_with msg
@@ -393,7 +398,7 @@ checkValidType ctxt ty
-- (and more complicated) errors in checkAmbiguity
; checkNoErrs $
do { check_type ve ty
- ; checkUserTypeError ty
+ ; checkUserTypeError ctxt ty
; traceTc "done ct" (ppr ty) }
-- Check for ambiguous types. See Note [When to call checkAmbiguity]