From d48fbfea5f7b760ec3d13dd2947257986c095b75 Mon Sep 17 00:00:00 2001 From: Simon Peyton Jones Date: Thu, 13 Apr 2023 12:10:29 +0100 Subject: Stop if type constructors have kind errors Otherwise we get knock-on errors, such as #23252. This makes GHC fail a bit sooner, and I have not attempted to add recovery code, to add a fake TyCon place of the erroneous one, in an attempt to get more type errors in one pass. We could do that (perhaps) if there was a call for it. --- compiler/GHC/Tc/TyCl.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'compiler') diff --git a/compiler/GHC/Tc/TyCl.hs b/compiler/GHC/Tc/TyCl.hs index 966b612a50..de6ef49225 100644 --- a/compiler/GHC/Tc/TyCl.hs +++ b/compiler/GHC/Tc/TyCl.hs @@ -248,7 +248,13 @@ tcTyClDecls tyclds kisig_env role_annots = do { -- Step 1: kind-check this group and returns the final -- (possibly-polymorphic) kind of each TyCon and Class -- See Note [Kind checking for type and class decls] - (tc_tycons, kindless) <- kcTyClGroup kisig_env tyclds + (tc_tycons, kindless) <- checkNoErrs $ + kcTyClGroup kisig_env tyclds + -- checkNoErrs: If the TyCons are ill-kinded, stop now. Else we + -- can get follow-on errors. Example: #23252, where the TyCon + -- had an ill-scoped kind forall (d::k) k (a::k). blah + -- and that ill-scoped kind made role inference fall over. + ; traceTc "tcTyAndCl generalized kinds" (vcat (map ppr_tc_tycon tc_tycons)) -- Step 2: type-check all groups together, returning -- cgit v1.2.1