summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/GHC/Hs/Type.hs23
-rw-r--r--compiler/GHC/Rename/HsType.hs100
-rw-r--r--compiler/GHC/Tc/Errors/Ppr.hs107
-rw-r--r--compiler/GHC/Tc/Errors/Types.hs171
-rw-r--r--compiler/GHC/Types/Error/Codes.hs11
-rw-r--r--testsuite/tests/linear/should_fail/T18888.stderr5
-rw-r--r--testsuite/tests/module/mod61.stderr2
-rw-r--r--testsuite/tests/overloadedrecflds/should_fail/T13132_duplicaterecflds.stderr2
-rw-r--r--testsuite/tests/parser/should_fail/readFail016.stderr2
-rw-r--r--testsuite/tests/parser/should_fail/readFail023.stderr2
-rw-r--r--testsuite/tests/polykinds/BadKindVar.stderr4
-rw-r--r--testsuite/tests/polykinds/T14710.stderr24
-rw-r--r--testsuite/tests/polykinds/T16762b.stderr5
-rw-r--r--testsuite/tests/polykinds/T7151.stderr4
-rw-r--r--testsuite/tests/rename/should_compile/ExplicitForAllRules1.stderr2
-rw-r--r--testsuite/tests/rename/should_compile/T5331.stderr6
-rw-r--r--testsuite/tests/rename/should_fail/T11663.stderr12
-rw-r--r--testsuite/tests/rename/should_fail/rnfail017.stderr4
-rw-r--r--testsuite/tests/rename/should_fail/rnfail019.stderr2
-rw-r--r--testsuite/tests/saks/should_fail/T16722.stderr4
-rw-r--r--testsuite/tests/th/T8412.stderr2
-rw-r--r--testsuite/tests/th/TH_Promoted1Tuple.stderr5
-rw-r--r--testsuite/tests/th/TH_unresolvedInfix2.stderr2
-rw-r--r--testsuite/tests/typecheck/should_fail/T18252a.stderr2
-rw-r--r--testsuite/tests/typecheck/should_fail/T8306.stderr2
-rw-r--r--testsuite/tests/typecheck/should_fail/TyAppPat_NonlinearMultiAppPat.stderr2
-rw-r--r--testsuite/tests/typecheck/should_fail/TyAppPat_NonlinearMultiPat.stderr8
-rw-r--r--testsuite/tests/typecheck/should_fail/TyAppPat_NonlinearSinglePat.stderr2
-rw-r--r--testsuite/tests/typecheck/should_fail/TyAppPat_ScopedTyVarConflict.stderr4
-rw-r--r--testsuite/tests/typecheck/should_fail/all.T1
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail094.stderr5
31 files changed, 395 insertions, 132 deletions
diff --git a/compiler/GHC/Hs/Type.hs b/compiler/GHC/Hs/Type.hs
index 968fc99b73..eb3a955269 100644
--- a/compiler/GHC/Hs/Type.hs
+++ b/compiler/GHC/Hs/Type.hs
@@ -60,6 +60,8 @@ module GHC.Hs.Type (
selectorAmbiguousFieldOcc,
unambiguousFieldOcc, ambiguousFieldOcc,
+ OpName(..),
+
mkAnonWildCardTy, pprAnonWildCard,
hsOuterTyVarNames, hsOuterExplicitBndrs, mapHsOuterImplicit,
@@ -109,6 +111,7 @@ import GHC.Types.Name
import GHC.Types.Name.Reader ( RdrName )
import GHC.Types.Var ( VarBndr, visArgTypeLike )
import GHC.Core.TyCo.Rep ( Type(..) )
+import GHC.Builtin.Names ( negateName )
import GHC.Builtin.Types( manyDataConName, oneDataConName, mkTupleStr )
import GHC.Core.Ppr ( pprOccWithTick)
import GHC.Core.Type
@@ -950,6 +953,26 @@ ambiguousFieldOcc (FieldOcc sel rdr) = Unambiguous sel rdr
{-
************************************************************************
* *
+ OpName
+* *
+************************************************************************
+-}
+
+-- | Name of an operator in an operator application or section
+data OpName = NormalOp Name -- ^ A normal identifier
+ | NegateOp -- ^ Prefix negation
+ | UnboundOp RdrName -- ^ An unbound identifier
+ | RecFldOp (FieldOcc GhcRn) -- ^ A record field occurrence
+
+instance Outputable OpName where
+ ppr (NormalOp n) = ppr n
+ ppr NegateOp = ppr negateName
+ ppr (UnboundOp uv) = ppr uv
+ ppr (RecFldOp fld) = ppr fld
+
+{-
+************************************************************************
+* *
\subsection{Pretty printing}
* *
************************************************************************
diff --git a/compiler/GHC/Rename/HsType.hs b/compiler/GHC/Rename/HsType.hs
index 06ff333ed8..500a6f8407 100644
--- a/compiler/GHC/Rename/HsType.hs
+++ b/compiler/GHC/Rename/HsType.hs
@@ -45,7 +45,6 @@ import GHC.Prelude
import {-# SOURCE #-} GHC.Rename.Splice( rnSpliceType )
import GHC.Core.TyCo.FVs ( tyCoVarsOfTypeList )
-import GHC.Driver.Session
import GHC.Hs
import GHC.Rename.Env
import GHC.Rename.Doc
@@ -56,8 +55,7 @@ import GHC.Rename.Fixity ( lookupFieldFixityRn, lookupFixityRn
, lookupTyFixityRn )
import GHC.Rename.Unbound ( notInScopeErr, WhereLooking(WL_LocalOnly) )
import GHC.Tc.Errors.Types
-import GHC.Tc.Errors.Ppr ( pprScopeError
- , inHsDocContext, pprHsDocContext )
+import GHC.Tc.Errors.Ppr ( pprHsDocContext )
import GHC.Tc.Utils.Monad
import GHC.Types.Name.Reader
import GHC.Builtin.Names
@@ -215,14 +213,7 @@ rnHsPatSigTypeBindingVars ctxt sigType thing_inside = case sigType of
-- Should the inner `a` refer to the outer one? shadow it? We are, as yet, undecided,
-- so we currently reject.
when (not (null varsInScope)) $
- addErr $ mkTcRnUnknownMessage $ mkPlainError noHints $
- vcat
- [ text "Type variable" <> plural varsInScope
- <+> hcat (punctuate (text ",") (map (quotes . ppr) varsInScope))
- <+> isOrAre varsInScope
- <+> text "already in scope."
- , text "Type applications in patterns must bind fresh variables, without shadowing."
- ]
+ addErr $ TcRnBindVarAlreadyInScope varsInScope
(wcVars, ibVars) <- partition_nwcs varsNotInScope
rnImplicitTvBndrs ctxt Nothing ibVars $ \ ibVars' -> do
(wcVars', hs_ty', fvs) <- rnWcBody ctxt wcVars hs_ty
@@ -371,7 +362,7 @@ rnHsSigType ctx level
= setSrcSpanA loc $
do { traceRn "rnHsSigType" (ppr sig_ty)
; case outer_bndrs of
- HsOuterExplicit{} -> checkPolyKinds env sig_ty
+ HsOuterExplicit{} -> checkPolyKinds env (HsSigType sig_ty)
HsOuterImplicit{} -> pure ()
; imp_vars <- filterInScopeM $ extractHsTyRdrTyVars body
; bindHsOuterTyVarBndrs ctx Nothing imp_vars outer_bndrs $ \outer_bndrs' ->
@@ -447,9 +438,7 @@ rnImplicitTvBndrs ctx mb_assoc implicit_vs_with_dups thing_inside
= do { implicit_vs <- forM (NE.groupAllWith unLoc $ implicit_vs_with_dups) $ \case
(x :| []) -> return x
(x :| _) -> do
- let msg = mkTcRnUnknownMessage $ mkPlainError noHints $
- text "Variable" <+> text "`" <> ppr x <> text "'" <+> text "would be bound multiple times by" <+> pprHsDocContext ctx <> text "."
- addErr msg
+ addErr $ TcRnBindMultipleVariables ctx x
return x
; traceRn "rnImplicitTvBndrs" $
@@ -572,7 +561,7 @@ rnLHsTyKi env (L loc ty)
rnHsTyKi :: RnTyKiEnv -> HsType GhcPs -> RnM (HsType GhcRn, FreeVars)
rnHsTyKi env ty@(HsForAllTy { hst_tele = tele, hst_body = tau })
- = do { checkPolyKinds env ty
+ = do { checkPolyKinds env (HsType ty)
; bindHsForAllTelescope (rtke_ctxt env) tele $ \ tele' ->
do { (tau', fvs) <- rnLHsTyKi env tau
; return ( HsForAllTy { hst_xforall = noExtField
@@ -593,9 +582,7 @@ rnHsTyKi env (HsTyVar _ ip (L loc rdr_name))
= do { when (isRnKindLevel env && isRdrTyVar rdr_name) $
unlessXOptM LangExt.PolyKinds $ addErr $
TcRnWithHsDocContext (rtke_ctxt env) $
- mkTcRnUnknownMessage $ mkPlainError noHints $
- vcat [ text "Unexpected kind variable" <+> quotes (ppr rdr_name)
- , text "Perhaps you intended to use PolyKinds" ]
+ TcRnUnexpectedKindVar rdr_name
-- Any type variable at the kind level is illegal without the use
-- of PolyKinds (see #14710)
; name <- rnTyVar env rdr_name
@@ -684,16 +671,13 @@ rnHsTyKi env sumTy@(HsSumTy x tys)
rnHsTyKi env tyLit@(HsTyLit src t)
= do { data_kinds <- xoptM LangExt.DataKinds
; unless data_kinds (addErr (dataKindsErr env tyLit))
- ; when (negLit t) (addErr negLitErr)
+ ; when (negLit t) (addErr $ TcRnNegativeNumTypeLiteral tyLit)
; return (HsTyLit src (rnHsTyLit t), emptyFVs) }
where
negLit :: HsTyLit (GhcPass p) -> Bool
negLit (HsStrTy _ _) = False
negLit (HsNumTy _ i) = i < 0
negLit (HsCharTy _ _) = False
- negLitErr :: TcRnMessage
- negLitErr = mkTcRnUnknownMessage $ mkPlainError noHints $
- text "Illegal literal in type (type literals must not be negative):" <+> ppr tyLit
rnHsTyKi env (HsAppTy _ ty1 ty2)
= do { (ty1', fvs1) <- rnLHsTyKi env ty1
@@ -734,12 +718,10 @@ rnHsTyKi env (XHsType ty)
check_in_scope :: RdrName -> RnM ()
check_in_scope rdr_name = do
mb_name <- lookupLocalOccRn_maybe rdr_name
- -- TODO: refactor this to avoid mkTcRnUnknownMessage
when (isNothing mb_name) $
addErr $
TcRnWithHsDocContext (rtke_ctxt env) $
- mkTcRnUnknownMessage $ mkPlainError noHints $
- pprScopeError rdr_name (notInScopeErr WL_LocalOnly rdr_name)
+ TcRnNotInScope (notInScopeErr WL_LocalOnly rdr_name) rdr_name [] []
rnHsTyKi env ty@(HsExplicitListTy _ ip tys)
= do { data_kinds <- xoptM LangExt.DataKinds
@@ -894,27 +876,22 @@ wildCardsAllowed env
---------------
-- | Ensures either that we're in a type or that -XPolyKinds is set
-checkPolyKinds :: Outputable ty
- => RnTyKiEnv
- -> ty -- ^ type
- -> RnM ()
+checkPolyKinds :: RnTyKiEnv
+ -> HsTypeOrSigType GhcPs
+ -> RnM ()
checkPolyKinds env ty
| isRnKindLevel env
= do { polykinds <- xoptM LangExt.PolyKinds
; unless polykinds $
- addErr $ mkTcRnUnknownMessage $ mkPlainError noHints $
- (text "Illegal kind:" <+> ppr ty $$
- text "Did you mean to enable PolyKinds?") }
+ addErr $ TcRnIllegalKind ty True }
checkPolyKinds _ _ = return ()
-notInKinds :: Outputable ty
- => RnTyKiEnv
- -> ty
+notInKinds :: RnTyKiEnv
+ -> HsType GhcPs
-> RnM ()
notInKinds env ty
| isRnKindLevel env
- = addErr $ mkTcRnUnknownMessage $ mkPlainError noHints $
- text "Illegal kind:" <+> ppr ty
+ = addErr $ TcRnIllegalKind (HsType ty) False
notInKinds _ _ = return ()
{- *****************************************************
@@ -1413,18 +1390,6 @@ data NegationHandling = ReassociateNegation | KeepNegationIntact
----------------------------
--- | Name of an operator in an operator application or section
-data OpName = NormalOp Name -- ^ A normal identifier
- | NegateOp -- ^ Prefix negation
- | UnboundOp RdrName -- ^ An unbound identifier
- | RecFldOp (FieldOcc GhcRn) -- ^ A record field occurrence
-
-instance Outputable OpName where
- ppr (NormalOp n) = ppr n
- ppr NegateOp = ppr negateName
- ppr (UnboundOp uv) = ppr uv
- ppr (RecFldOp fld) = ppr fld
-
get_op :: LHsExpr GhcRn -> OpName
-- An unbound name could be either HsVar or HsUnboundVar
-- See GHC.Rename.Expr.rnUnboundVar
@@ -1608,34 +1573,20 @@ precParseErr op1@(n1,_) op2@(n2,_)
| is_unbound n1 || is_unbound n2
= return () -- Avoid error cascade
| otherwise
- = addErr $ mkTcRnUnknownMessage $ mkPlainError noHints $
- hang (text "Precedence parsing error")
- 4 (hsep [text "cannot mix", ppr_opfix op1, text "and",
- ppr_opfix op2,
- text "in the same infix expression"])
+ = addErr $ TcRnPrecedenceParsingError op1 op2
sectionPrecErr :: (OpName,Fixity) -> (OpName,Fixity) -> HsExpr GhcPs -> RnM ()
sectionPrecErr op@(n1,_) arg_op@(n2,_) section
| is_unbound n1 || is_unbound n2
= return () -- Avoid error cascade
| otherwise
- = addErr $ mkTcRnUnknownMessage $ mkPlainError noHints $
- vcat [text "The operator" <+> ppr_opfix op <+> text "of a section",
- nest 4 (sep [text "must have lower precedence than that of the operand,",
- nest 2 (text "namely" <+> ppr_opfix arg_op)]),
- nest 4 (text "in the section:" <+> quotes (ppr section))]
+ = addErr $ TcRnSectionPrecedenceError op arg_op section
is_unbound :: OpName -> Bool
is_unbound (NormalOp n) = isUnboundName n
is_unbound UnboundOp{} = True
is_unbound _ = False
-ppr_opfix :: (OpName, Fixity) -> SDoc
-ppr_opfix (op, fixity) = pp_op <+> brackets (ppr fixity)
- where
- pp_op | NegateOp <- op = text "prefix `-'"
- | otherwise = quotes (ppr op)
-
{- *****************************************************
* *
@@ -1645,9 +1596,7 @@ ppr_opfix (op, fixity) = pp_op <+> brackets (ppr fixity)
unexpectedPatSigTypeErr :: HsPatSigType GhcPs -> TcRnMessage
unexpectedPatSigTypeErr ty
- = mkTcRnUnknownMessage $ mkPlainError noHints $
- hang (text "Illegal type signature:" <+> quotes (ppr ty))
- 2 (text "Type signatures are only allowed in patterns with ScopedTypeVariables")
+ = TcRnUnexpectedPatSigType ty
badKindSigErr :: HsDocContext -> LHsType GhcPs -> TcM ()
badKindSigErr doc (L loc ty)
@@ -1657,21 +1606,16 @@ badKindSigErr doc (L loc ty)
dataKindsErr :: RnTyKiEnv -> HsType GhcPs -> TcRnMessage
dataKindsErr env thing
- = mkTcRnUnknownMessage $ mkPlainError noHints $
- hang (text "Illegal" <+> pp_what <> colon <+> quotes (ppr thing))
- 2 (text "Perhaps you intended to use DataKinds")
+ = TcRnDataKindsError type_or_Kind thing
where
- pp_what | isRnKindLevel env = text "kind"
- | otherwise = text "type"
+ type_or_Kind | isRnKindLevel env = KindLevel
+ | otherwise = TypeLevel
warnUnusedForAll :: OutputableBndrFlag flag 'Renamed
=> HsDocContext -> LHsTyVarBndr flag GhcRn -> FreeVars -> TcM ()
warnUnusedForAll doc (L loc tv) used_names
= unless (hsTyVarName tv `elemNameSet` used_names) $ do
- let msg = mkTcRnUnknownMessage $
- mkPlainDiagnostic (WarningWithFlag Opt_WarnUnusedForalls) noHints $
- vcat [ text "Unused quantified type variable" <+> quotes (ppr tv)
- , inHsDocContext doc ]
+ let msg = TcRnUnusedQuantifiedTypeVar doc (HsTyVarBndrExistentialFlag tv)
addDiagnosticAt (locA loc) msg
warnCapturedTerm :: LocatedN RdrName -> Either [GlobalRdrElt] Name -> TcM ()
diff --git a/compiler/GHC/Tc/Errors/Ppr.hs b/compiler/GHC/Tc/Errors/Ppr.hs
index 09918d4014..2d056a31b1 100644
--- a/compiler/GHC/Tc/Errors/Ppr.hs
+++ b/compiler/GHC/Tc/Errors/Ppr.hs
@@ -1662,6 +1662,61 @@ instance Diagnostic TcRnMessage where
2 (vcat [ text "Expected:" <+> ppr fam_tc_name
, text " Actual:" <+> ppr eqn_tc_name ])
+ TcRnBindVarAlreadyInScope tv_names_in_scope
+ -> mkSimpleDecorated $
+ vcat
+ [ text "Type variable" <> plural tv_names_in_scope
+ <+> hcat (punctuate (text ",") (map (quotes . ppr) tv_names_in_scope))
+ <+> isOrAre tv_names_in_scope
+ <+> text "already in scope."
+ , text "Type applications in patterns must bind fresh variables, without shadowing."
+ ]
+
+ TcRnBindMultipleVariables ctx tv_name_w_loc
+ -> mkSimpleDecorated $
+ text "Variable" <+> text "`" <> ppr tv_name_w_loc <> text "'" <+> text "would be bound multiple times by" <+> pprHsDocContext ctx <> text "."
+
+ TcRnUnexpectedKindVar tv_name
+ -> mkSimpleDecorated $ text "Unexpected kind variable" <+> quotes (ppr tv_name)
+
+ TcRnNegativeNumTypeLiteral tyLit
+ -> mkSimpleDecorated $ text "Illegal literal in type (type literals must not be negative):" <+> ppr tyLit
+
+ TcRnIllegalKind ty_thing _
+ -> mkSimpleDecorated $ text "Illegal kind:" <+> (ppr ty_thing)
+
+ TcRnPrecedenceParsingError op1 op2
+ -> mkSimpleDecorated $
+ hang (text "Precedence parsing error")
+ 4 (hsep [text "cannot mix", ppr_opfix op1, text "and",
+ ppr_opfix op2,
+ text "in the same infix expression"])
+
+ TcRnSectionPrecedenceError op arg_op section
+ -> mkSimpleDecorated $
+ vcat [text "The operator" <+> ppr_opfix op <+> text "of a section",
+ nest 4 (sep [text "must have lower precedence than that of the operand,",
+ nest 2 (text "namely" <+> ppr_opfix arg_op)]),
+ nest 4 (text "in the section:" <+> quotes (ppr section))]
+
+ TcRnUnexpectedPatSigType ty
+ -> mkSimpleDecorated $
+ hang (text "Illegal type signature:" <+> quotes (ppr ty))
+ 2 (text "Type signatures are only allowed in patterns with ScopedTypeVariables")
+
+ TcRnIllegalKindSignature ty
+ -> mkSimpleDecorated $ text "Illegal kind signature:" <+> quotes (ppr ty)
+
+ TcRnUnusedQuantifiedTypeVar doc tyVar
+ -> mkSimpleDecorated $
+ vcat [ text "Unused quantified type variable" <+> quotes (ppr tyVar)
+ , inHsDocContext doc ]
+
+ TcRnDataKindsError typeOrKind thing
+ -> mkSimpleDecorated $
+ text "Illegal" <+> (text $ levelString typeOrKind) <> colon <+> quotes (ppr thing)
+
+
diagnosticReason = \case
TcRnUnknownMessage m
-> diagnosticReason m
@@ -2209,6 +2264,28 @@ instance Diagnostic TcRnMessage where
-> ErrorWithoutFlag
TcRnTyFamNameMismatch{}
-> ErrorWithoutFlag
+ TcRnBindVarAlreadyInScope{}
+ -> ErrorWithoutFlag
+ TcRnBindMultipleVariables{}
+ -> ErrorWithoutFlag
+ TcRnUnexpectedKindVar{}
+ -> ErrorWithoutFlag
+ TcRnNegativeNumTypeLiteral{}
+ -> ErrorWithoutFlag
+ TcRnIllegalKind{}
+ -> ErrorWithoutFlag
+ TcRnPrecedenceParsingError{}
+ -> ErrorWithoutFlag
+ TcRnSectionPrecedenceError{}
+ -> ErrorWithoutFlag
+ TcRnUnexpectedPatSigType{}
+ -> ErrorWithoutFlag
+ TcRnIllegalKindSignature{}
+ -> ErrorWithoutFlag
+ TcRnUnusedQuantifiedTypeVar{}
+ -> WarningWithFlag Opt_WarnUnusedForalls
+ TcRnDataKindsError{}
+ -> ErrorWithoutFlag
diagnosticHints = \case
TcRnUnknownMessage m
@@ -2782,6 +2859,30 @@ instance Diagnostic TcRnMessage where
-> [suggestExtension LangExt.IncoherentInstances]
TcRnTyFamNameMismatch{}
-> noHints
+ TcRnBindVarAlreadyInScope{}
+ -> noHints
+ TcRnBindMultipleVariables{}
+ -> noHints
+ TcRnUnexpectedKindVar{}
+ -> [suggestExtension LangExt.PolyKinds]
+ TcRnNegativeNumTypeLiteral{}
+ -> noHints
+ TcRnIllegalKind _ suggest_polyKinds
+ -> if suggest_polyKinds
+ then [suggestExtension LangExt.PolyKinds]
+ else noHints
+ TcRnPrecedenceParsingError{}
+ -> noHints
+ TcRnSectionPrecedenceError{}
+ -> noHints
+ TcRnUnexpectedPatSigType{}
+ -> [suggestExtension LangExt.ScopedTypeVariables]
+ TcRnIllegalKindSignature{}
+ -> [suggestExtension LangExt.KindSignatures]
+ TcRnUnusedQuantifiedTypeVar{}
+ -> noHints
+ TcRnDataKindsError{}
+ -> [suggestExtension LangExt.DataKinds]
diagnosticCode = constructorCode
@@ -2933,6 +3034,12 @@ pprRecordFieldPart = \case
RecordFieldPattern{} -> text "pattern"
RecordFieldUpdate -> text "update"
+ppr_opfix :: (OpName, Fixity) -> SDoc
+ppr_opfix (op, fixity) = pp_op <+> brackets (ppr fixity)
+ where
+ pp_op | NegateOp <- op = text "prefix `-'"
+ | otherwise = quotes (ppr op)
+
pprBindings :: [Name] -> SDoc
pprBindings = pprWithCommas (quotes . ppr)
diff --git a/compiler/GHC/Tc/Errors/Types.hs b/compiler/GHC/Tc/Errors/Types.hs
index 648074f4f3..14ff1ff6b7 100644
--- a/compiler/GHC/Tc/Errors/Types.hs
+++ b/compiler/GHC/Tc/Errors/Types.hs
@@ -1,7 +1,10 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE UndecidableInstances #-}
module GHC.Tc.Errors.Types (
-- * Main types
@@ -103,6 +106,8 @@ module GHC.Tc.Errors.Types (
, RoleValidationFailedReason(..)
, DisabledClassExtension(..)
, TyFamsDisabledReason(..)
+ , HsTypeOrSigType(..)
+ , HsTyVarBndrExistentialFlag(..)
) where
import GHC.Prelude
@@ -322,6 +327,7 @@ data TcRnMessage where
Test cases: th/T17804
-}
TcRnImplicitLift :: Name -> !ErrInfo -> TcRnMessage
+
{-| TcRnUnusedPatternBinds is a warning (controlled with -Wunused-pattern-binds)
that occurs if a pattern binding binds no variables at all, unless it is a
lone wild-card pattern, or a banged pattern.
@@ -335,6 +341,21 @@ data TcRnMessage where
Test cases: rename/{T13646,T17c,T17e,T7085}
-}
TcRnUnusedPatternBinds :: HsBind GhcRn -> TcRnMessage
+
+ {-| TcRnUnusedQuantifiedTypeVar is a warning that occurs if there are unused
+ quantified type variables.
+
+ Examples:
+ f :: forall a. Int -> Char
+
+ Test cases: rename/should_compile/ExplicitForAllRules1
+ rename/should_compile/T5331
+ -}
+ TcRnUnusedQuantifiedTypeVar
+ :: HsDocContext
+ -> HsTyVarBndrExistentialFlag -- ^ tyVar binder.
+ -> TcRnMessage
+
{-| TcRnDodgyImports is a warning (controlled with -Wdodgy-imports) that occurs when
an import of the form 'T(..)' or 'f(..)' does not actually import anything beside
'T'/'f' itself.
@@ -621,6 +642,16 @@ data TcRnMessage where
-}
TcRnCharLiteralOutOfRange :: !Char -> TcRnMessage
+ {-| TcRnNegativeNumTypeLiteral is an error that occurs whenever
+ a type-level number literal is negative.
+
+ type Neg = -1
+
+ Test cases: th/T8412
+ typecheck/should_fail/T8306
+ -}
+ TcRnNegativeNumTypeLiteral :: HsType GhcPs -> TcRnMessage
+
{-| TcRnIllegalWildcardsInConstructor is an error that occurs whenever
the record wildcards '..' are used inside a constructor without labeled fields.
@@ -1723,10 +1754,29 @@ data TcRnMessage where
-}
TcRnCapturedTermName :: RdrName -> Either [GlobalRdrElt] Name -> TcRnMessage
+ {-| TcRnTypeMultipleOccurenceOfBindVar is an error that occurs if a bound
+ type variable's name is already in use.
+ Example:
+ f :: forall a. ...
+ f (MkT @a ...) = ...
+
+ Test cases: TyAppPat_ScopedTyVarConflict TyAppPat_NonlinearMultiPat TyAppPat_NonlinearMultiAppPat
+ -}
+ TcRnBindVarAlreadyInScope :: [LocatedN RdrName] -> TcRnMessage
+
+ {-| TcRnBindMultipleVariables is an error that occurs in the case of
+ multiple occurrences of a bound variable.
+ Example:
+ foo (MkFoo @(a,a) ...) = ...
+
+ Test case: typecheck/should_fail/TyAppPat_NonlinearSinglePat
+ -}
+ TcRnBindMultipleVariables :: HsDocContext -> LocatedN RdrName -> TcRnMessage
+
{-| TcRnTypeEqualityOutOfScope is a warning (controlled by -Wtype-equality-out-of-scope)
that occurs when the type equality (a ~ b) is not in scope.
- Test case: T18862b
+ Test case: warnings/should_compile/T18862b
-}
TcRnTypeEqualityOutOfScope :: TcRnMessage
@@ -2106,6 +2156,31 @@ data TcRnMessage where
-> !(Maybe SuggestUnliftedTypes) -- ^ suggested extension
-> TcRnMessage
+ {-| TcRnUnexpectedKindVar is an error that occurs when the user
+ tries to use kind variables without -XPolyKinds.
+
+ Example:
+ f :: forall k a. Proxy (a :: k)
+
+ Test cases: polykinds/BadKindVar
+ polykinds/T14710
+ saks/should_fail/T16722
+ -}
+ TcRnUnexpectedKindVar :: RdrName -> TcRnMessage
+
+ {-| TcRnIllegalKind is used for a various illegal kinds errors including
+
+ Example:
+ type T :: forall k. Type -- without emabled -XPolyKinds
+
+ Test cases: polykinds/T16762b
+ -}
+ TcRnIllegalKind
+ :: HsTypeOrSigType GhcPs
+ -- ^ The illegal kind
+ -> Bool -- ^ Whether enabling -XPolyKinds should be suggested
+ -> TcRnMessage
+
{- TcRnClassKindNotConstraint is an error for a type class that has a kind that
is not equivalent to Constraint.
@@ -2167,6 +2242,43 @@ data TcRnMessage where
-> !MatchArgBadMatches
-> TcRnMessage
+ {-| TcRnUnexpectedPatSigType is an error occurring when there is
+ a type signature in a pattern without -XScopedTypeVariables extension
+
+ Examples:
+ f (a :: Bool) = ...
+
+ Test case: rename/should_fail/T11663
+ -}
+ TcRnUnexpectedPatSigType :: HsPatSigType GhcPs -> TcRnMessage
+
+ {-| TcRnIllegalKindSignature is an error occuring when there is
+ a kind signature without -XKindSignatures extension
+
+ Examples:
+ data Foo (a :: Nat) = ....
+
+ Test case: parser/should_fail/readFail036
+ -}
+ TcRnIllegalKindSignature :: HsType GhcPs -> TcRnMessage
+
+ {-| TcRnDataKindsError is an error occurring when there is
+ an illegal type or kind, probably required -XDataKinds
+ and is used without the enabled extension.
+
+ Examples:
+
+ type Foo = [Nat, Char]
+
+ type Bar = [Int, String]
+
+ Test cases: linear/should_fail/T18888
+ polykinds/T7151
+ th/TH_Promoted1Tuple
+ typecheck/should_fail/tcfail094
+ -}
+ TcRnDataKindsError :: TypeOrKind -> HsType GhcPs -> TcRnMessage
+
{- TcRnCannotBindScopedTyVarInPatSig is an error stating that scoped type
variables cannot be used in pattern bindings.
@@ -3638,6 +3750,43 @@ data TcRnMessage where
-> !Name -- ^ The name used in the equation
-> TcRnMessage
+ {-| TcRnPrecedenceParsingError is an error caused by attempting to
+ use operators with the same precedence in one infix expression.
+
+ Example:
+ eq :: (a ~ b ~ c) :~: ()
+
+ Test cases: module/mod61
+ parser/should_fail/readFail016
+ rename/should_fail/rnfail017
+ rename/should_fail/T9077
+ typecheck/should_fail/T18252a
+ -}
+ TcRnPrecedenceParsingError
+ :: (OpName, Fixity) -- ^ first operator's name and fixity
+ -> (OpName, Fixity) -- ^ second operator's name and fixity
+ -> TcRnMessage
+
+ {-| TcRnPrecedenceParsingError is an error caused by attempting to
+ use an operator with higher precedence than the operand.
+
+ Example:
+ k = (-3 **)
+ where
+ (**) = const
+ infixl 7 **
+
+ Test cases: overloadedrecflds/should_fail/T13132_duplicaterecflds
+ parser/should_fail/readFail023
+ rename/should_fail/rnfail019
+ th/TH_unresolvedInfix2
+ -}
+ TcRnSectionPrecedenceError
+ :: (OpName, Fixity) -- ^ first operator's name and fixity
+ -> (OpName, Fixity) -- ^ argument operator
+ -> HsExpr GhcPs -- ^ Section
+ -> TcRnMessage
+
deriving Generic
-- | Things forbidden in @type data@ declarations.
@@ -4076,6 +4225,7 @@ instance Outputable Exported where
ppr IsNotExported = text "IsNotExported"
ppr IsExported = text "IsExported"
+
--------------------------------------------------------------------------------
--
-- Errors used in GHC.Tc.Errors
@@ -5023,3 +5173,22 @@ data TyFamsDisabledReason
= TyFamsDisabledFamily !Name
| TyFamsDisabledInstance !TyCon
deriving (Generic)
+
+-- | Either `HsType p` or `HsSigType p`.
+--
+-- Used for reporting errors in `TcRnIllegalKind`.
+data HsTypeOrSigType p
+ = HsType (HsType p)
+ | HsSigType (HsSigType p)
+
+instance OutputableBndrId p => Outputable (HsTypeOrSigType (GhcPass p)) where
+ ppr (HsType ty) = ppr ty
+ ppr (HsSigType sig_ty) = ppr sig_ty
+
+-- | A wrapper around HsTyVarBndr.
+-- Used for reporting errors in `TcRnUnusedQuantifiedTypeVar`.
+data HsTyVarBndrExistentialFlag = forall flag. OutputableBndrFlag flag 'Renamed =>
+ HsTyVarBndrExistentialFlag (HsTyVarBndr flag GhcRn)
+
+instance Outputable HsTyVarBndrExistentialFlag where
+ ppr (HsTyVarBndrExistentialFlag hsTyVarBndr) = ppr hsTyVarBndr
diff --git a/compiler/GHC/Types/Error/Codes.hs b/compiler/GHC/Types/Error/Codes.hs
index 90950b3bb4..8f02023fc9 100644
--- a/compiler/GHC/Types/Error/Codes.hs
+++ b/compiler/GHC/Types/Error/Codes.hs
@@ -434,6 +434,9 @@ type family GhcDiagnosticCode c = n | n -> c where
GhcDiagnosticCode "TcRnIllegalImplicitParameterBindings" = 50730
GhcDiagnosticCode "TcRnIllegalTupleSection" = 59155
GhcDiagnosticCode "TcRnTermNameInType" = 37479
+ GhcDiagnosticCode "TcRnUnexpectedKindVar" = 12875
+ GhcDiagnosticCode "TcRnNegativeNumTypeLiteral" = 93632
+ GhcDiagnosticCode "TcRnUnusedQuantifiedTypeVar" = 54180
GhcDiagnosticCode "TcRnUntickedPromotedThing" = 49957
GhcDiagnosticCode "TcRnIllegalBuiltinSyntax" = 39716
@@ -468,6 +471,12 @@ type family GhcDiagnosticCode c = n | n -> c where
GhcDiagnosticCode "TcRnNonOverloadedSpecialisePragma" = 35827
GhcDiagnosticCode "TcRnSpecialiseNotVisible" = 85337
GhcDiagnosticCode "TcRnIllegalTypeOperatorDecl" = 50649
+ GhcDiagnosticCode "TcRnBindVarAlreadyInScope" = 69710
+ GhcDiagnosticCode "TcRnBindMultipleVariables" = 92957
+ GhcDiagnosticCode "TcRnIllegalKind" = 64861
+ GhcDiagnosticCode "TcRnUnexpectedPatSigType" = 74097
+ GhcDiagnosticCode "TcRnIllegalKindSignature" = 91382
+ GhcDiagnosticCode "TcRnDataKindsError" = 68567
GhcDiagnosticCode "TcRnIllegalHsigDefaultMethods" = 93006
GhcDiagnosticCode "TcRnHsigFixityMismatch" = 93007
@@ -588,6 +597,8 @@ type family GhcDiagnosticCode c = n | n -> c where
-- TcRnTyFamsDisabled/TyFamsDisabledReason
GhcDiagnosticCode "TyFamsDisabledFamily" = 39191
GhcDiagnosticCode "TyFamsDisabledInstance" = 06206
+ GhcDiagnosticCode "TcRnPrecedenceParsingError" = 88747
+ GhcDiagnosticCode "TcRnSectionPrecedenceError" = 46878
-- IllegalNewtypeReason
GhcDiagnosticCode "DoesNotHaveSingleField" = 23517
diff --git a/testsuite/tests/linear/should_fail/T18888.stderr b/testsuite/tests/linear/should_fail/T18888.stderr
index c224a5b331..aa2032db1d 100644
--- a/testsuite/tests/linear/should_fail/T18888.stderr
+++ b/testsuite/tests/linear/should_fail/T18888.stderr
@@ -1,3 +1,4 @@
-T18888.hs:4:9:
- Illegal type: ‘001’ Perhaps you intended to use DataKinds
+T18888.hs:4:9: [GHC-68567]
+ Illegal type: ‘001’
+ Suggested fix: Perhaps you intended to use DataKinds \ No newline at end of file
diff --git a/testsuite/tests/module/mod61.stderr b/testsuite/tests/module/mod61.stderr
index cce1dfe611..0382f217ed 100644
--- a/testsuite/tests/module/mod61.stderr
+++ b/testsuite/tests/module/mod61.stderr
@@ -1,4 +1,4 @@
-mod61.hs:3:11:
+mod61.hs:3:11: [GHC-88747]
Precedence parsing error
cannot mix ‘==’ [infix 4] and ‘==’ [infix 4] in the same infix expression
diff --git a/testsuite/tests/overloadedrecflds/should_fail/T13132_duplicaterecflds.stderr b/testsuite/tests/overloadedrecflds/should_fail/T13132_duplicaterecflds.stderr
index 462b00416c..11374466ec 100644
--- a/testsuite/tests/overloadedrecflds/should_fail/T13132_duplicaterecflds.stderr
+++ b/testsuite/tests/overloadedrecflds/should_fail/T13132_duplicaterecflds.stderr
@@ -7,7 +7,7 @@ T13132_duplicaterecflds.hs:7:16: error:
or the field ‘runContT’ of record ‘ContT2’,
defined at T13132_duplicaterecflds.hs:5:33
-T13132_duplicaterecflds.hs:9:11: error:
+T13132_duplicaterecflds.hs:9:11: error: [GHC-46878]
The operator ‘runContT’ [infixl 9] of a section
must have lower precedence than that of the operand,
namely ‘y’ [infixl 9]
diff --git a/testsuite/tests/parser/should_fail/readFail016.stderr b/testsuite/tests/parser/should_fail/readFail016.stderr
index 33ccbed470..feb8942530 100644
--- a/testsuite/tests/parser/should_fail/readFail016.stderr
+++ b/testsuite/tests/parser/should_fail/readFail016.stderr
@@ -1,4 +1,4 @@
-readFail016.hs:7:1:
+readFail016.hs:7:1: [GHC-88747]
Precedence parsing error
cannot mix ‘|-’ [infix 6] and ‘:’ [infixr 5] in the same infix expression
diff --git a/testsuite/tests/parser/should_fail/readFail023.stderr b/testsuite/tests/parser/should_fail/readFail023.stderr
index 7c60be5108..7d28c3400d 100644
--- a/testsuite/tests/parser/should_fail/readFail023.stderr
+++ b/testsuite/tests/parser/should_fail/readFail023.stderr
@@ -1,5 +1,5 @@
-readFail023.hs:9:5:
+readFail023.hs:9:5: [GHC-46878]
The operator ‘**’ [infixl 7] of a section
must have lower precedence than that of the operand,
namely prefix `-' [infixl 6]
diff --git a/testsuite/tests/polykinds/BadKindVar.stderr b/testsuite/tests/polykinds/BadKindVar.stderr
index 19944a4df8..a0fcb59fd1 100644
--- a/testsuite/tests/polykinds/BadKindVar.stderr
+++ b/testsuite/tests/polykinds/BadKindVar.stderr
@@ -1,5 +1,5 @@
-BadKindVar.hs:9:21: error:
+BadKindVar.hs:9:21: error: [GHC-12875]
Unexpected kind variable ‘k’
- Perhaps you intended to use PolyKinds
In the type signature for ‘f’
+ Suggested fix: Perhaps you intended to use PolyKinds
diff --git a/testsuite/tests/polykinds/T14710.stderr b/testsuite/tests/polykinds/T14710.stderr
index fa83a74fc8..6fc8866af7 100644
--- a/testsuite/tests/polykinds/T14710.stderr
+++ b/testsuite/tests/polykinds/T14710.stderr
@@ -1,30 +1,30 @@
-T14710.hs:10:21: error:
+T14710.hs:10:21: error: [GHC-12875]
Unexpected kind variable ‘a’
- Perhaps you intended to use PolyKinds
In a class method signature for ‘c1’
+ Suggested fix: Perhaps you intended to use PolyKinds
-T14710.hs:11:22: error:
+T14710.hs:11:22: error: [GHC-12875]
Unexpected kind variable ‘a’
- Perhaps you intended to use PolyKinds
In a class method signature for ‘c2’
+ Suggested fix: Perhaps you intended to use PolyKinds
-T14710.hs:16:23: error:
+T14710.hs:16:23: error: [GHC-12875]
Unexpected kind variable ‘a’
- Perhaps you intended to use PolyKinds
In the type signature for ‘g1’
+ Suggested fix: Perhaps you intended to use PolyKinds
-T14710.hs:19:24: error:
+T14710.hs:19:24: error: [GHC-12875]
Unexpected kind variable ‘a’
- Perhaps you intended to use PolyKinds
In the type signature for ‘g2’
+ Suggested fix: Perhaps you intended to use PolyKinds
-T14710.hs:22:31: error:
+T14710.hs:22:31: error: [GHC-12875]
Unexpected kind variable ‘k’
- Perhaps you intended to use PolyKinds
In the type signature for ‘h1’
+ Suggested fix: Perhaps you intended to use PolyKinds
-T14710.hs:25:22: error:
+T14710.hs:25:22: error: [GHC-12875]
Unexpected kind variable ‘k’
- Perhaps you intended to use PolyKinds
In the type signature for ‘h2’
+ Suggested fix: Perhaps you intended to use PolyKinds
diff --git a/testsuite/tests/polykinds/T16762b.stderr b/testsuite/tests/polykinds/T16762b.stderr
index 3da5c88856..e77f332f17 100644
--- a/testsuite/tests/polykinds/T16762b.stderr
+++ b/testsuite/tests/polykinds/T16762b.stderr
@@ -1,4 +1,5 @@
-T16762b.hs:8:11: error:
+T16762b.hs:8:11: error: [GHC-64861]
Illegal kind: forall k. Type
- Did you mean to enable PolyKinds?
+ Suggested fix: Perhaps you intended to use PolyKinds
+
diff --git a/testsuite/tests/polykinds/T7151.stderr b/testsuite/tests/polykinds/T7151.stderr
index 8b9ff9040e..71a39d2c4f 100644
--- a/testsuite/tests/polykinds/T7151.stderr
+++ b/testsuite/tests/polykinds/T7151.stderr
@@ -1,4 +1,4 @@
-T7151.hs:3:12:
+T7151.hs:3:12: [GHC-68567]
Illegal type: ‘[Int, String]’
- Perhaps you intended to use DataKinds
+ Suggested fix: Perhaps you intended to use DataKinds
diff --git a/testsuite/tests/rename/should_compile/ExplicitForAllRules1.stderr b/testsuite/tests/rename/should_compile/ExplicitForAllRules1.stderr
index d74f06b452..49a55fc84c 100644
--- a/testsuite/tests/rename/should_compile/ExplicitForAllRules1.stderr
+++ b/testsuite/tests/rename/should_compile/ExplicitForAllRules1.stderr
@@ -6,6 +6,6 @@ ExplicitForAllRules1.hs:45:31: warning: [GHC-64088] [-Wforall-identifier (in -Wd
Consider using another name, such as
‘forAll’, ‘for_all’, or ‘forall_’.
-ExplicitForAllRules1.hs:48:31: warning: [-Wunused-foralls (in -Wextra)]
+ExplicitForAllRules1.hs:48:31: warning: [GHC-54180] [-Wunused-foralls (in -Wextra)]
Unused quantified type variable ‘b’
In the rewrite rule "example7"
diff --git a/testsuite/tests/rename/should_compile/T5331.stderr b/testsuite/tests/rename/should_compile/T5331.stderr
index d57daceb0a..9ab7c83933 100644
--- a/testsuite/tests/rename/should_compile/T5331.stderr
+++ b/testsuite/tests/rename/should_compile/T5331.stderr
@@ -1,12 +1,12 @@
-T5331.hs:8:17: warning: [-Wunused-foralls (in -Wextra)]
+T5331.hs:8:17: warning: [GHC-54180] [-Wunused-foralls (in -Wextra)]
Unused quantified type variable ‘a’
In the definition of data constructor ‘S1’
-T5331.hs:11:16: warning: [-Wunused-foralls (in -Wextra)]
+T5331.hs:11:16: warning: [GHC-54180] [-Wunused-foralls (in -Wextra)]
Unused quantified type variable ‘a’
In the definition of data constructor ‘W1’
-T5331.hs:13:13: warning: [-Wunused-foralls (in -Wextra)]
+T5331.hs:13:13: warning: [GHC-54180] [-Wunused-foralls (in -Wextra)]
Unused quantified type variable ‘a’
In the type signature for ‘f’
diff --git a/testsuite/tests/rename/should_fail/T11663.stderr b/testsuite/tests/rename/should_fail/T11663.stderr
index 77e2999cec..4602d1992a 100644
--- a/testsuite/tests/rename/should_fail/T11663.stderr
+++ b/testsuite/tests/rename/should_fail/T11663.stderr
@@ -1,16 +1,20 @@
-T11663.hs:6:12: error:
+T11663.hs:6:12: error: [GHC-74097]
Illegal type signature: ‘Int’
Type signatures are only allowed in patterns with ScopedTypeVariables
+ Suggested fix: Perhaps you intended to use ScopedTypeVariables
-T11663.hs:7:9: error:
+T11663.hs:7:9: error: [GHC-74097]
Illegal type signature: ‘Int’
Type signatures are only allowed in patterns with ScopedTypeVariables
+ Suggested fix: Perhaps you intended to use ScopedTypeVariables
-T11663.hs:8:22: error:
+T11663.hs:8:22: error: [GHC-74097]
Illegal type signature: ‘Int’
Type signatures are only allowed in patterns with ScopedTypeVariables
+ Suggested fix: Perhaps you intended to use ScopedTypeVariables
-T11663.hs:9:32: error:
+T11663.hs:9:32: error: [GHC-74097]
Illegal type signature: ‘Int’
Type signatures are only allowed in patterns with ScopedTypeVariables
+ Suggested fix: Perhaps you intended to use ScopedTypeVariables
diff --git a/testsuite/tests/rename/should_fail/rnfail017.stderr b/testsuite/tests/rename/should_fail/rnfail017.stderr
index de2990864f..b286d22c60 100644
--- a/testsuite/tests/rename/should_fail/rnfail017.stderr
+++ b/testsuite/tests/rename/should_fail/rnfail017.stderr
@@ -1,8 +1,8 @@
-rnfail017.hs:5:10:
+rnfail017.hs:5:10: [GHC-88747]
Precedence parsing error
cannot mix ‘+’ [infixl 6] and prefix `-' [infixl 6] in the same infix expression
-rnfail017.hs:6:10:
+rnfail017.hs:6:10: [GHC-88747]
Precedence parsing error
cannot mix ‘*’ [infixl 7] and prefix `-' [infixl 6] in the same infix expression
diff --git a/testsuite/tests/rename/should_fail/rnfail019.stderr b/testsuite/tests/rename/should_fail/rnfail019.stderr
index 2520641bd6..797b97900e 100644
--- a/testsuite/tests/rename/should_fail/rnfail019.stderr
+++ b/testsuite/tests/rename/should_fail/rnfail019.stderr
@@ -1,5 +1,5 @@
-rnfail019.hs:5:9:
+rnfail019.hs:5:9: [GHC-46878]
The operator ‘:’ [infixr 5] of a section
must have lower precedence than that of the operand,
namely ‘:’ [infixr 5]
diff --git a/testsuite/tests/saks/should_fail/T16722.stderr b/testsuite/tests/saks/should_fail/T16722.stderr
index 0b50bb868d..94bb0bc82a 100644
--- a/testsuite/tests/saks/should_fail/T16722.stderr
+++ b/testsuite/tests/saks/should_fail/T16722.stderr
@@ -1,5 +1,5 @@
-T16722.hs:8:11: error:
+T16722.hs:8:11: error: [GHC-12875]
Unexpected kind variable ‘k’
- Perhaps you intended to use PolyKinds
In the standalone kind signature for D
+ Suggested fix: Perhaps you intended to use PolyKinds \ No newline at end of file
diff --git a/testsuite/tests/th/T8412.stderr b/testsuite/tests/th/T8412.stderr
index 9e69b8e880..cf7e458abd 100644
--- a/testsuite/tests/th/T8412.stderr
+++ b/testsuite/tests/th/T8412.stderr
@@ -1,4 +1,4 @@
-T8412.hs:5:11: error:
+T8412.hs:5:11: error: [GHC-93632]
• Illegal literal in type (type literals must not be negative): -1
• In the untyped splice: $(return $ LitT $ NumTyLit (- 1))
diff --git a/testsuite/tests/th/TH_Promoted1Tuple.stderr b/testsuite/tests/th/TH_Promoted1Tuple.stderr
index 2453cb26d5..fa5d55ebbf 100644
--- a/testsuite/tests/th/TH_Promoted1Tuple.stderr
+++ b/testsuite/tests/th/TH_Promoted1Tuple.stderr
@@ -1,3 +1,4 @@
-TH_Promoted1Tuple.hs:7:2: error:
- Illegal type: ‘'MkSolo Int’ Perhaps you intended to use DataKinds
+TH_Promoted1Tuple.hs:7:2: error: [GHC-68567]
+ Illegal type: ‘'MkSolo Int’
+ Suggested fix: Perhaps you intended to use DataKinds \ No newline at end of file
diff --git a/testsuite/tests/th/TH_unresolvedInfix2.stderr b/testsuite/tests/th/TH_unresolvedInfix2.stderr
index 50d56a02ff..b51699570c 100644
--- a/testsuite/tests/th/TH_unresolvedInfix2.stderr
+++ b/testsuite/tests/th/TH_unresolvedInfix2.stderr
@@ -1,5 +1,5 @@
-TH_unresolvedInfix2.hs:14:9: error:
+TH_unresolvedInfix2.hs:14:9: error: [GHC-46878]
• The operator ‘:+’ [infixl 6] of a section
must have lower precedence than that of the operand,
namely ‘:+’ [infixl 6]
diff --git a/testsuite/tests/typecheck/should_fail/T18252a.stderr b/testsuite/tests/typecheck/should_fail/T18252a.stderr
index 14908263a2..af3a941c1a 100644
--- a/testsuite/tests/typecheck/should_fail/T18252a.stderr
+++ b/testsuite/tests/typecheck/should_fail/T18252a.stderr
@@ -1,4 +1,4 @@
-T18252a.hs:8:10:
+T18252a.hs:8:10: [GHC-88747]
Precedence parsing error
cannot mix ‘~’ [infix 4] and ‘~’ [infix 4] in the same infix expression \ No newline at end of file
diff --git a/testsuite/tests/typecheck/should_fail/T8306.stderr b/testsuite/tests/typecheck/should_fail/T8306.stderr
index 471da8d776..432b62201b 100644
--- a/testsuite/tests/typecheck/should_fail/T8306.stderr
+++ b/testsuite/tests/typecheck/should_fail/T8306.stderr
@@ -1,3 +1,3 @@
-T8306.hs:4:10:
+T8306.hs:4:10: [GHC-93632]
Illegal literal in type (type literals must not be negative): -1
diff --git a/testsuite/tests/typecheck/should_fail/TyAppPat_NonlinearMultiAppPat.stderr b/testsuite/tests/typecheck/should_fail/TyAppPat_NonlinearMultiAppPat.stderr
index 87655cb6cf..757ed8f183 100644
--- a/testsuite/tests/typecheck/should_fail/TyAppPat_NonlinearMultiAppPat.stderr
+++ b/testsuite/tests/typecheck/should_fail/TyAppPat_NonlinearMultiAppPat.stderr
@@ -1,4 +1,4 @@
-TyAppPat_NonlinearMultiAppPat.hs:13:6: error:
+TyAppPat_NonlinearMultiAppPat.hs:13:6: error: [GHC-69710]
Type variable ‘a’ is already in scope.
Type applications in patterns must bind fresh variables, without shadowing.
diff --git a/testsuite/tests/typecheck/should_fail/TyAppPat_NonlinearMultiPat.stderr b/testsuite/tests/typecheck/should_fail/TyAppPat_NonlinearMultiPat.stderr
index 82c78654f7..3641e4b39d 100644
--- a/testsuite/tests/typecheck/should_fail/TyAppPat_NonlinearMultiPat.stderr
+++ b/testsuite/tests/typecheck/should_fail/TyAppPat_NonlinearMultiPat.stderr
@@ -1,16 +1,16 @@
-TyAppPat_NonlinearMultiPat.hs:10:19: error:
+TyAppPat_NonlinearMultiPat.hs:10:19: error: [GHC-69710]
Type variable ‘a’ is already in scope.
Type applications in patterns must bind fresh variables, without shadowing.
-TyAppPat_NonlinearMultiPat.hs:11:18: error:
+TyAppPat_NonlinearMultiPat.hs:11:18: error: [GHC-69710]
Type variable ‘a’ is already in scope.
Type applications in patterns must bind fresh variables, without shadowing.
-TyAppPat_NonlinearMultiPat.hs:12:19: error:
+TyAppPat_NonlinearMultiPat.hs:12:19: error: [GHC-69710]
Type variable ‘a’ is already in scope.
Type applications in patterns must bind fresh variables, without shadowing.
-TyAppPat_NonlinearMultiPat.hs:13:18: error:
+TyAppPat_NonlinearMultiPat.hs:13:18: error: [GHC-69710]
Type variable ‘a’ is already in scope.
Type applications in patterns must bind fresh variables, without shadowing.
diff --git a/testsuite/tests/typecheck/should_fail/TyAppPat_NonlinearSinglePat.stderr b/testsuite/tests/typecheck/should_fail/TyAppPat_NonlinearSinglePat.stderr
index 0d06da09d2..c0118ccf82 100644
--- a/testsuite/tests/typecheck/should_fail/TyAppPat_NonlinearSinglePat.stderr
+++ b/testsuite/tests/typecheck/should_fail/TyAppPat_NonlinearSinglePat.stderr
@@ -1,3 +1,3 @@
-TyAppPat_NonlinearSinglePat.hs:13:6: error:
+TyAppPat_NonlinearSinglePat.hs:13:6: error: [GHC-92957]
Variable `a' would be bound multiple times by a type argument.
diff --git a/testsuite/tests/typecheck/should_fail/TyAppPat_ScopedTyVarConflict.stderr b/testsuite/tests/typecheck/should_fail/TyAppPat_ScopedTyVarConflict.stderr
index 5ce650e4be..eea80116d8 100644
--- a/testsuite/tests/typecheck/should_fail/TyAppPat_ScopedTyVarConflict.stderr
+++ b/testsuite/tests/typecheck/should_fail/TyAppPat_ScopedTyVarConflict.stderr
@@ -1,8 +1,8 @@
-TyAppPat_ScopedTyVarConflict.hs:10:6: error:
+TyAppPat_ScopedTyVarConflict.hs:10:6: error: [GHC-69710]
Type variable ‘a’ is already in scope.
Type applications in patterns must bind fresh variables, without shadowing.
-TyAppPat_ScopedTyVarConflict.hs:11:6: error:
+TyAppPat_ScopedTyVarConflict.hs:11:6: error: [GHC-69710]
Type variable ‘a’ is already in scope.
Type applications in patterns must bind fresh variables, without shadowing.
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index ebcec31f8d..0ae1fdd646 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -591,6 +591,7 @@ test('T17567', normal, compile_fail, [''])
test('T17562', normal, compile_fail, [''])
test('T17567StupidTheta', normal, compile_fail, [''])
test('T15474', normal, compile_fail, [''])
+test('T18252a', normal, compile_fail, [''])
test('T18455', normal, compile_fail, [''])
test('T18714', normal, compile_fail, [''])
test('T18723a', normal, compile_fail, [''])
diff --git a/testsuite/tests/typecheck/should_fail/tcfail094.stderr b/testsuite/tests/typecheck/should_fail/tcfail094.stderr
index d3f5e7623a..1928582727 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail094.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail094.stderr
@@ -1,3 +1,4 @@
-tcfail094.hs:7:14:
- Illegal type: ‘1’ Perhaps you intended to use DataKinds
+tcfail094.hs:7:14: [GHC-68567]
+ Illegal type: ‘1’
+ Suggested fix: Perhaps you intended to use DataKinds