From 0f6fb7d309cbe69dcd534c14155d68c981895ab2 Mon Sep 17 00:00:00 2001 From: Simon Peyton Jones Date: Thu, 29 Jul 2021 11:22:07 +0100 Subject: TypeError is OK on the RHS of a type synonym 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 --- compiler/GHC/Tc/Validity.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'compiler/GHC/Tc/Validity.hs') 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] -- cgit v1.2.1