summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-05-06 14:52:53 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-05-12 21:41:43 -0400
commitbfabf94f63b6644bd32982fd13ea0c8bca9aeae4 (patch)
treeb185749a9676a57c226dab9681fa3c4ba0415dd3 /compiler/GHC/Tc
parentda56ed41b62ab132db6d62637c11076985410b24 (diff)
downloadhaskell-bfabf94f63b6644bd32982fd13ea0c8bca9aeae4.tar.gz
Replace CPP assertions with Haskell functions
There is no reason to use CPP. __LINE__ and __FILE__ macros are now better replaced with GHC's CallStack. As a bonus, assert error messages now contain more information (function name, column). Here is the mapping table (HasCallStack omitted): * ASSERT: assert :: Bool -> a -> a * MASSERT: massert :: Bool -> m () * ASSERTM: assertM :: m Bool -> m () * ASSERT2: assertPpr :: Bool -> SDoc -> a -> a * MASSERT2: massertPpr :: Bool -> SDoc -> m () * ASSERTM2: assertPprM :: m Bool -> SDoc -> m ()
Diffstat (limited to 'compiler/GHC/Tc')
-rw-r--r--compiler/GHC/Tc/Deriv.hs9
-rw-r--r--compiler/GHC/Tc/Deriv/Generate.hs9
-rw-r--r--compiler/GHC/Tc/Deriv/Generics.hs7
-rw-r--r--compiler/GHC/Tc/Deriv/Infer.hs19
-rw-r--r--compiler/GHC/Tc/Errors.hs15
-rw-r--r--compiler/GHC/Tc/Gen/App.hs2
-rw-r--r--compiler/GHC/Tc/Gen/Expr.hs19
-rw-r--r--compiler/GHC/Tc/Gen/Head.hs3
-rw-r--r--compiler/GHC/Tc/Gen/HsType.hs9
-rw-r--r--compiler/GHC/Tc/Gen/Pat.hs11
-rw-r--r--compiler/GHC/Tc/Gen/Splice.hs13
-rw-r--r--compiler/GHC/Tc/Instance/Family.hs5
-rw-r--r--compiler/GHC/Tc/Instance/FunDeps.hs6
-rw-r--r--compiler/GHC/Tc/Module.hs15
-rw-r--r--compiler/GHC/Tc/Solver.hs7
-rw-r--r--compiler/GHC/Tc/Solver/Canonical.hs17
-rw-r--r--compiler/GHC/Tc/Solver/Interact.hs9
-rw-r--r--compiler/GHC/Tc/Solver/Monad.hs6
-rw-r--r--compiler/GHC/Tc/Solver/Rewrite.hs9
-rw-r--r--compiler/GHC/Tc/TyCl.hs26
-rw-r--r--compiler/GHC/Tc/TyCl/Build.hs18
-rw-r--r--compiler/GHC/Tc/TyCl/Class.hs3
-rw-r--r--compiler/GHC/Tc/TyCl/Instance.hs3
-rw-r--r--compiler/GHC/Tc/TyCl/PatSyn.hs2
-rw-r--r--compiler/GHC/Tc/TyCl/Utils.hs13
-rw-r--r--compiler/GHC/Tc/Types.hs2
-rw-r--r--compiler/GHC/Tc/Types/Evidence.hs8
-rw-r--r--compiler/GHC/Tc/Utils/Backpack.hs6
-rw-r--r--compiler/GHC/Tc/Utils/Instantiate.hs5
-rw-r--r--compiler/GHC/Tc/Utils/Monad.hs1
-rw-r--r--compiler/GHC/Tc/Utils/TcMType.hs36
-rw-r--r--compiler/GHC/Tc/Utils/TcType.hs25
-rw-r--r--compiler/GHC/Tc/Utils/Unify.hs21
-rw-r--r--compiler/GHC/Tc/Utils/Zonk.hs22
-rw-r--r--compiler/GHC/Tc/Validity.hs2
35 files changed, 205 insertions, 178 deletions
diff --git a/compiler/GHC/Tc/Deriv.hs b/compiler/GHC/Tc/Deriv.hs
index a899349702..fa1a0afb45 100644
--- a/compiler/GHC/Tc/Deriv.hs
+++ b/compiler/GHC/Tc/Deriv.hs
@@ -61,6 +61,7 @@ import GHC.Types.SrcLoc
import GHC.Utils.Misc
import GHC.Utils.Outputable as Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import GHC.Utils.Logger
import GHC.Data.Bag
import GHC.Utils.FV as FV (fvVarList, unionFV, mkFVs)
@@ -1556,7 +1557,7 @@ mkNewTypeEqn newtype_strat dit@(DerivInstTys { dit_cls_tys = cls_tys
cant_derive_err = ppUnless eta_ok eta_msg
eta_msg = text "cannot eta-reduce the representation type enough"
- MASSERT( cls_tys `lengthIs` (classArity cls - 1) )
+ massert (cls_tys `lengthIs` (classArity cls - 1))
if newtype_strat
then
-- Since the user explicitly asked for GeneralizedNewtypeDeriving,
@@ -1962,7 +1963,7 @@ doDerivInstErrorChecks1 mechanism =
at_last_cls_tv_in_kind kind
= last_cls_tv `elemVarSet` exactTyCoVarsOfType kind
at_tcs = classATs cls
- last_cls_tv = ASSERT( notNull cls_tyvars )
+ last_cls_tv = assert (notNull cls_tyvars )
last cls_tyvars
cant_derive_err
@@ -2056,8 +2057,8 @@ genDerivStuff mechanism loc clas inst_tys tyvars
tyfam_insts <-
-- canDeriveAnyClass should ensure that this code can't be reached
-- unless -XDeriveAnyClass is enabled.
- ASSERT2( isValid (canDeriveAnyClass dflags)
- , ppr "genDerivStuff: bad derived class" <+> ppr clas )
+ assertPpr (isValid (canDeriveAnyClass dflags))
+ (ppr "genDerivStuff: bad derived class" <+> ppr clas) $
mapM (tcATDefault loc mini_subst emptyNameSet)
(classATItems clas)
return ( emptyBag, [] -- No method bindings are needed...
diff --git a/compiler/GHC/Tc/Deriv/Generate.hs b/compiler/GHC/Tc/Deriv/Generate.hs
index 5f2f69bee2..69af151327 100644
--- a/compiler/GHC/Tc/Deriv/Generate.hs
+++ b/compiler/GHC/Tc/Deriv/Generate.hs
@@ -77,6 +77,7 @@ import GHC.Utils.Misc
import GHC.Types.Var
import GHC.Utils.Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import GHC.Utils.Lexeme
import GHC.Data.FastString
import GHC.Data.Pair
@@ -730,7 +731,7 @@ gen_Bounded_binds loc tycon _
| isEnumerationTyCon tycon
= (listToBag [ min_bound_enum, max_bound_enum ], emptyBag)
| otherwise
- = ASSERT(isSingleton data_cons)
+ = assert (isSingleton data_cons)
(listToBag [ min_bound_1con, max_bound_1con ], emptyBag)
where
data_cons = tyConDataCons tycon
@@ -1137,7 +1138,7 @@ gen_Read_binds get_fixity loc tycon _
data_con_str con = occNameString (getOccName con)
- read_arg a ty = ASSERT( not (isUnliftedType ty) )
+ read_arg a ty = assert (not (isUnliftedType ty)) $
noLocA (mkPsBindStmt noAnn (nlVarPat a) (nlHsVarApps step_RDR [readPrec_RDR]))
-- When reading field labels we might encounter
@@ -1210,7 +1211,7 @@ gen_Show_binds get_fixity loc tycon tycon_args
pats_etc data_con
| nullary_con = -- skip the showParen junk...
- ASSERT(null bs_needed)
+ assert (null bs_needed)
([nlWildPat, con_pat], mk_showString_app op_con_str)
| otherwise =
([a_Pat, con_pat],
@@ -1945,7 +1946,7 @@ gen_Newtype_binds :: SrcSpan
gen_Newtype_binds loc' cls inst_tvs inst_tys rhs_ty
= do let ats = classATs cls
(binds, sigs) = mapAndUnzip mk_bind_and_sig (classMethods cls)
- atf_insts <- ASSERT( all (not . isDataFamilyTyCon) ats )
+ atf_insts <- assert (all (not . isDataFamilyTyCon) ats) $
mapM mk_atf_inst ats
return ( listToBag binds
, sigs
diff --git a/compiler/GHC/Tc/Deriv/Generics.hs b/compiler/GHC/Tc/Deriv/Generics.hs
index 5eff74aaa1..9e2dbf07df 100644
--- a/compiler/GHC/Tc/Deriv/Generics.hs
+++ b/compiler/GHC/Tc/Deriv/Generics.hs
@@ -54,6 +54,7 @@ import GHC.Types.Var.Env
import GHC.Types.Var.Set (elemVarSet)
import GHC.Utils.Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import GHC.Data.FastString
import GHC.Utils.Misc
@@ -388,7 +389,7 @@ mkBindsRep dflags gk tycon = (binds, sigs)
(from_alts, to_alts) = mkSum gk_ (1 :: US) datacons
where gk_ = case gk of
Gen0 -> Gen0_
- Gen1 -> ASSERT(tyvars `lengthAtLeast` 1)
+ Gen1 -> assert (tyvars `lengthAtLeast` 1) $
Gen1_ (last tyvars)
where tyvars = tyConTyVars tycon
@@ -439,7 +440,7 @@ tc_mkRepFamInsts gk tycon inst_tys =
; let -- `tyvars` = [a,b]
(tyvars, gk_) = case gk of
Gen0 -> (all_tyvars, Gen0_)
- Gen1 -> ASSERT(not $ null all_tyvars)
+ Gen1 -> assert (not $ null all_tyvars)
(init all_tyvars, Gen1_ $ last all_tyvars)
where all_tyvars = tyConTyVars tycon
@@ -618,7 +619,7 @@ tc_mkRepTy gk_ tycon k =
-- The Bool is True if this constructor has labelled fields
prod :: [Type] -> [HsSrcBang] -> [HsImplBang] -> [FieldLabel] -> Type
prod l sb ib fl = foldBal mkProd (mkTyConApp u1 [k])
- [ ASSERT(null fl || lengthExceeds fl j)
+ [ assert (null fl || lengthExceeds fl j) $
arg t sb' ib' (if null fl
then Nothing
else Just (fl !! j))
diff --git a/compiler/GHC/Tc/Deriv/Infer.hs b/compiler/GHC/Tc/Deriv/Infer.hs
index 5ce54339c6..5caf62e6c0 100644
--- a/compiler/GHC/Tc/Deriv/Infer.hs
+++ b/compiler/GHC/Tc/Deriv/Infer.hs
@@ -26,6 +26,7 @@ import GHC.Utils.Error
import GHC.Tc.Utils.Instantiate
import GHC.Utils.Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import GHC.Data.Pair
import GHC.Builtin.Names
import GHC.Tc.Deriv.Utils
@@ -113,12 +114,12 @@ inferConstraints mechanism
-- Constraints arising from superclasses
-- See Note [Superclasses of derived instance]
cls_tvs = classTyVars main_cls
- sc_constraints = ASSERT2( equalLength cls_tvs inst_tys
- , ppr main_cls <+> ppr inst_tys )
+ sc_constraints = assertPpr (equalLength cls_tvs inst_tys)
+ (ppr main_cls <+> ppr inst_tys)
[ mkThetaOrigin (mkDerivOrigin wildcard)
TypeLevel [] [] [] $
substTheta cls_subst (classSCTheta main_cls) ]
- cls_subst = ASSERT( equalLength cls_tvs inst_tys )
+ cls_subst = assert (equalLength cls_tvs inst_tys) $
zipTvSubst cls_tvs inst_tys
; (inferred_constraints, tvs', inst_tys') <- infer_constraints
@@ -269,7 +270,7 @@ inferConstraintsStock (DerivInstTys { dit_cls_tys = cls_tys
substTheta tc_subst (tyConStupidTheta rep_tc) ]
tc_subst = -- See the comment with all_rep_tc_args for an
-- explanation of this assertion
- ASSERT( equalLength rep_tc_tvs all_rep_tc_args )
+ assert (equalLength rep_tc_tvs all_rep_tc_args) $
zipTvSubst rep_tc_tvs all_rep_tc_args
-- Extra Data constraints
@@ -308,9 +309,9 @@ inferConstraintsStock (DerivInstTys { dit_cls_tys = cls_tys
-- Generic1 needs Functor
-- See Note [Getting base classes]
| is_generic1
- -> ASSERT( rep_tc_tvs `lengthExceeds` 0 )
+ -> assert (rep_tc_tvs `lengthExceeds` 0) $
-- Generic1 has a single kind variable
- ASSERT( cls_tys `lengthIs` 1 )
+ assert (cls_tys `lengthIs` 1) $
do { functorClass <- lift $ tcLookupClass functorClassName
; pure $ con_arg_constraints
$ get_gen1_constraints functorClass }
@@ -319,9 +320,9 @@ inferConstraintsStock (DerivInstTys { dit_cls_tys = cls_tys
| otherwise
-> -- See the comment with all_rep_tc_args for an explanation of
-- this assertion
- ASSERT2( equalLength rep_tc_tvs all_rep_tc_args
- , ppr main_cls <+> ppr rep_tc
- $$ ppr rep_tc_tvs $$ ppr all_rep_tc_args )
+ assertPpr (equalLength rep_tc_tvs all_rep_tc_args)
+ ( ppr main_cls <+> ppr rep_tc
+ $$ ppr rep_tc_tvs $$ ppr all_rep_tc_args) $
do { let (arg_constraints, tvs', inst_tys')
= con_arg_constraints get_std_constrained_tys
; lift $ traceTc "inferConstraintsStock" $ vcat
diff --git a/compiler/GHC/Tc/Errors.hs b/compiler/GHC/Tc/Errors.hs
index 9de37b0313..40810ee619 100644
--- a/compiler/GHC/Tc/Errors.hs
+++ b/compiler/GHC/Tc/Errors.hs
@@ -59,6 +59,7 @@ import GHC.Utils.Misc
import GHC.Data.FastString
import GHC.Utils.Outputable as O
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import GHC.Types.SrcLoc
import GHC.Driver.Session
import GHC.Driver.Ppr
@@ -555,7 +556,7 @@ reportWanteds ctxt tc_lvl (WC { wc_simple = simples, wc_impl = implics
-- says to suppress
; let ctxt2 = ctxt { cec_suppress = cec_suppress ctxt || cec_suppress ctxt1 }
; (_, leftovers) <- tryReporters ctxt2 report2 cts1
- ; MASSERT2( null leftovers, ppr leftovers )
+ ; massertPpr (null leftovers) (ppr leftovers)
-- All the Derived ones have been filtered out of simples
-- by the constraint solver. This is ok; we don't want
@@ -1629,8 +1630,8 @@ mkTyVarEqErr' dflags ctxt report ct tv1 ty2
-- See Note [Error messages for untouchables]
| (implic:_) <- cec_encl ctxt -- Get the innermost context
, Implic { ic_given = given, ic_tclvl = lvl, ic_info = skol_info } <- implic
- = ASSERT2( not (isTouchableMetaTyVar lvl tv1)
- , ppr tv1 $$ ppr lvl ) -- See Note [Error messages for untouchables]
+ = assertPpr (not (isTouchableMetaTyVar lvl tv1))
+ (ppr tv1 $$ ppr lvl) $ -- See Note [Error messages for untouchables]
let msg = misMatchMsg ctxt ct ty1 ty2
tclvl_extra = important $
nest 2 $
@@ -1800,7 +1801,7 @@ extraTyVarEqInfo ctxt tv1 ty2
extraTyVarInfo :: ReportErrCtxt -> TcTyVar -> SDoc
extraTyVarInfo ctxt tv
- = ASSERT2( isTyVar tv, ppr tv )
+ = assertPpr (isTyVar tv) (ppr tv) $
case tcTyVarDetails tv of
SkolemTv {} -> pprSkols ctxt [tv]
RuntimeUnk {} -> quotes (ppr tv) <+> text "is an interactive-debugger skolem"
@@ -2344,7 +2345,7 @@ Warn of loopy local equalities that were dropped.
mkDictErr :: ReportErrCtxt -> [Ct] -> TcM Report
mkDictErr ctxt cts
- = ASSERT( not (null cts) )
+ = assert (not (null cts)) $
do { inst_envs <- tcGetInstEnvs
; let min_cts = elim_superclasses cts
lookups = map (lookup_cls_inst inst_envs) min_cts
@@ -2518,7 +2519,7 @@ mk_dict_err ctxt@(CEC {cec_encl = implics}) (ct, (matches, unifiers, unsafe_over
-- Normal overlap error
overlap_msg
- = ASSERT( not (null matches) )
+ = assert (not (null matches)) $
vcat [ addArising orig (text "Overlapping instances for"
<+> pprType (mkClassPred clas tys))
@@ -2571,7 +2572,7 @@ mk_dict_err ctxt@(CEC {cec_encl = implics}) (ct, (matches, unifiers, unsafe_over
-- Overlap error because of Safe Haskell (first
-- match should be the most specific match)
safe_haskell_msg
- = ASSERT( matches `lengthIs` 1 && not (null unsafe_ispecs) )
+ = assert (matches `lengthIs` 1 && not (null unsafe_ispecs)) $
vcat [ addArising orig (text "Unsafe overlapping instances for"
<+> pprType (mkClassPred clas tys))
, sep [text "The matching instance is:",
diff --git a/compiler/GHC/Tc/Gen/App.hs b/compiler/GHC/Tc/Gen/App.hs
index 4f4f53f1cf..1c5876df52 100644
--- a/compiler/GHC/Tc/Gen/App.hs
+++ b/compiler/GHC/Tc/Gen/App.hs
@@ -991,7 +991,7 @@ qlUnify delta ty1 ty2
----------------
go_kappa bvs kappa ty2
- = ASSERT2( isMetaTyVar kappa, ppr kappa )
+ = assertPpr (isMetaTyVar kappa) (ppr kappa) $
do { info <- readMetaTyVar kappa
; case info of
Indirect ty1 -> go bvs ty1 ty2
diff --git a/compiler/GHC/Tc/Gen/Expr.hs b/compiler/GHC/Tc/Gen/Expr.hs
index 0ff73863cc..edcd4fc4d5 100644
--- a/compiler/GHC/Tc/Gen/Expr.hs
+++ b/compiler/GHC/Tc/Gen/Expr.hs
@@ -77,6 +77,7 @@ import GHC.Data.List.SetOps
import GHC.Data.Maybe
import GHC.Utils.Outputable as Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import Control.Monad
import GHC.Core.Class(classTyCon)
import GHC.Types.Unique.Set ( UniqSet, mkUniqSet, elementOfUniqSet, nonDetEltsUniqSet )
@@ -642,7 +643,7 @@ following.
-- GHC.Hs.Expr. This is why we match on 'rupd_flds = Left rbnds' here
-- and panic otherwise.
tcExpr expr@(RecordUpd { rupd_expr = record_expr, rupd_flds = Left rbnds }) res_ty
- = ASSERT( notNull rbnds )
+ = assert (notNull rbnds) $
do { -- STEP -2: typecheck the record_expr, the record to be updated
(record_expr', record_rho) <- tcScalingUsage Many $ tcInferRho record_expr
-- Record update drops some of the content of the record (namely the
@@ -679,7 +680,7 @@ tcExpr expr@(RecordUpd { rupd_expr = record_expr, rupd_flds = Left rbnds }) res_
-- See note [Mixed Record Selectors]
; let (data_sels, pat_syn_sels) =
partition isDataConRecordSelector sel_ids
- ; MASSERT( all isPatSynRecordSelector pat_syn_sels )
+ ; massert (all isPatSynRecordSelector pat_syn_sels)
; checkTc ( null data_sels || null pat_syn_sels )
( mixedSelectors data_sels pat_syn_sels )
@@ -713,7 +714,7 @@ tcExpr expr@(RecordUpd { rupd_expr = record_expr, rupd_flds = Left rbnds }) res_
; checkTc (not (null relevant_cons)) (badFieldsUpd rbinds con_likes)
-- Take apart a representative constructor
- ; let con1 = ASSERT( not (null relevant_cons) ) head relevant_cons
+ ; let con1 = assert (not (null relevant_cons) ) head relevant_cons
(con1_tvs, _, _, _prov_theta, req_theta, scaled_con1_arg_tys, _)
= conLikeFullSig con1
con1_arg_tys = map scaledThing scaled_con1_arg_tys
@@ -940,7 +941,7 @@ arithSeqEltType (Just fl) res_ty
----------------
tcTupArgs :: [HsTupArg GhcRn] -> [TcSigmaType] -> TcM [HsTupArg GhcTc]
tcTupArgs args tys
- = do MASSERT( equalLength args tys )
+ = do massert (equalLength args tys)
checkTupSize (length args)
mapM go (args `zip` tys)
where
@@ -1036,11 +1037,11 @@ tcSynArgE orig sigma_ty syn_ty thing_inside
-- another nested arrow is too much for now,
-- but I bet we'll never need this
- ; MASSERT2( case arg_shape of
+ ; massertPpr (case arg_shape of
SynFun {} -> False;
- _ -> True
- , text "Too many nested arrows in SyntaxOpType" $$
- pprCtOrigin orig )
+ _ -> True)
+ (text "Too many nested arrows in SyntaxOpType" $$
+ pprCtOrigin orig)
; let arg_mult = scaledMult arg_ty
; tcSynArgA orig arg_tc_ty [] arg_shape $
@@ -1501,7 +1502,7 @@ badFieldsUpd rbinds data_cons
-- are redundant and can be dropped.
map (fst . head) $ groupBy ((==) `on` snd) growingSets
- aMember = ASSERT( not (null members) ) fst (head members)
+ aMember = assert (not (null members) ) fst (head members)
(members, nonMembers) = partition (or . snd) membership
-- For each field, which constructors contain the field?
diff --git a/compiler/GHC/Tc/Gen/Head.hs b/compiler/GHC/Tc/Gen/Head.hs
index feef214055..9767681607 100644
--- a/compiler/GHC/Tc/Gen/Head.hs
+++ b/compiler/GHC/Tc/Gen/Head.hs
@@ -72,6 +72,7 @@ import GHC.Utils.Misc
import GHC.Data.Maybe
import GHC.Utils.Outputable as Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import Control.Monad
import Data.Function
@@ -1206,7 +1207,7 @@ addFunResCtxt fun args fun_res_ty env_ty thing_inside
Just env_ty -> zonkTcType env_ty
Nothing ->
do { dumping <- doptM Opt_D_dump_tc_trace
- ; MASSERT( dumping )
+ ; massert dumping
; newFlexiTyVarTy liftedTypeKind }
; let -- See Note [Splitting nested sigma types in mismatched
-- function types]
diff --git a/compiler/GHC/Tc/Gen/HsType.hs b/compiler/GHC/Tc/Gen/HsType.hs
index 26bb301361..18af6a8ea4 100644
--- a/compiler/GHC/Tc/Gen/HsType.hs
+++ b/compiler/GHC/Tc/Gen/HsType.hs
@@ -119,6 +119,7 @@ import GHC.Utils.Misc
import GHC.Types.Unique.Supply
import GHC.Utils.Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import GHC.Data.FastString
import GHC.Builtin.Names hiding ( wildCardName )
import GHC.Driver.Session
@@ -1273,7 +1274,7 @@ tc_hs_type mode rn_ty@(HsExplicitTupleTy _ tys) exp_kind
--------- Constraint types
tc_hs_type mode rn_ty@(HsIParamTy _ (L _ n) ty) exp_kind
- = do { MASSERT( isTypeLevel (mode_tyki mode) )
+ = do { massert (isTypeLevel (mode_tyki mode))
; ty' <- tc_lhs_type mode ty liftedTypeKind
; let n' = mkStrLitTy $ hsIPNameFS n
; ipClass <- tcLookupClass ipClassName
@@ -1755,8 +1756,8 @@ mkAppTyM subst fun (Named (Bndr tv _)) arg
mk_app_ty :: TcType -> TcType -> TcType
-- This function just adds an ASSERT for mkAppTyM's precondition
mk_app_ty fun arg
- = ASSERT2( isPiTy fun_kind
- , ppr fun <+> dcolon <+> ppr fun_kind $$ ppr arg )
+ = assertPpr (isPiTy fun_kind)
+ (ppr fun <+> dcolon <+> ppr fun_kind $$ ppr arg) $
mkAppTy fun arg
where
fun_kind = tcTypeKind fun
@@ -2662,7 +2663,7 @@ kcCheckDeclHeader_sig kisig name flav
invis_to_tcb :: TyCoBinder -> TcM TyConBinder
invis_to_tcb tb = do
(tcb, stv) <- zipped_to_tcb (ZippedBinder tb Nothing)
- MASSERT(null stv)
+ massert (null stv)
return tcb
-- Check that the inline kind annotation on a binder is valid
diff --git a/compiler/GHC/Tc/Gen/Pat.hs b/compiler/GHC/Tc/Gen/Pat.hs
index 671955feb7..f21b5d9593 100644
--- a/compiler/GHC/Tc/Gen/Pat.hs
+++ b/compiler/GHC/Tc/Gen/Pat.hs
@@ -65,6 +65,7 @@ import GHC.Types.Var.Set
import GHC.Utils.Misc
import GHC.Utils.Outputable as Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import qualified GHC.LanguageExtensions as LangExt
import Control.Arrow ( second )
import Control.Monad
@@ -221,7 +222,7 @@ tcPatBndr penv@(PE { pe_ctxt = LetPat { pc_lvl = bind_lvl
| otherwise -- No signature
= do { (co, bndr_ty) <- case scaledThing exp_pat_ty of
Check pat_ty -> promoteTcType bind_lvl pat_ty
- Infer infer_res -> ASSERT( bind_lvl == ir_lvl infer_res )
+ Infer infer_res -> assert (bind_lvl == ir_lvl infer_res) $
-- If we were under a constructor that bumped the
-- level, we'd be in checking mode (see tcConArg)
-- hence this assertion
@@ -339,7 +340,7 @@ tc_lpat pat_ty penv (L span pat) thing_inside
tc_lpats :: [Scaled ExpSigmaType]
-> Checker [LPat GhcRn] [LPat GhcTc]
tc_lpats tys penv pats
- = ASSERT2( equalLength pats tys, ppr pats $$ ppr tys )
+ = assertPpr (equalLength pats tys) (ppr pats $$ ppr tys) $
tcMultiple (\ penv' (p,t) -> tc_lpat t penv' p)
penv
(zipEqual "tc_lpats" pats tys)
@@ -536,8 +537,8 @@ Fortunately that's what matchExpectedFunTySigma returns anyway.
| otherwise = unmangled_result
; pat_ty <- readExpType (scaledThing pat_ty)
- ; ASSERT( con_arg_tys `equalLength` pats ) -- Syntactically enforced
- return (mkHsWrapPat coi possibly_mangled_result pat_ty, res)
+ ; massert (con_arg_tys `equalLength` pats) -- Syntactically enforced
+ ; return (mkHsWrapPat coi possibly_mangled_result pat_ty, res)
}
SumPat _ pat alt arity -> do
@@ -1271,7 +1272,7 @@ tcConArgs con_like arg_tys tenv penv con_args thing_inside = case con_args of
-- The normal case, when the field comes from the right constructor
(pat_ty : extras) -> do
traceTc "find_field" (ppr pat_ty <+> ppr extras)
- ASSERT( null extras ) (return pat_ty)
+ assert (null extras) (return pat_ty)
field_tys :: [(FieldLabel, Scaled TcType)]
field_tys = zip (conLikeFieldLabels con_like) arg_tys
diff --git a/compiler/GHC/Tc/Gen/Splice.hs b/compiler/GHC/Tc/Gen/Splice.hs
index 8a6c4399e7..8748fd3786 100644
--- a/compiler/GHC/Tc/Gen/Splice.hs
+++ b/compiler/GHC/Tc/Gen/Splice.hs
@@ -120,6 +120,7 @@ import GHC.Unit.Module.Deps
import GHC.Utils.Misc
import GHC.Utils.Panic as Panic
+import GHC.Utils.Panic.Plain
import GHC.Utils.Lexeme
import GHC.Utils.Outputable
import GHC.Utils.Logger
@@ -238,7 +239,7 @@ tcUntypedBracket rn_expr brack ps res_ty
-- we want to reflect that in the overall type of the bracket.
; ps' <- case quoteWrapperTyVarTy <$> brack_info of
Just m_var -> mapM (tcPendingSplice m_var) ps
- Nothing -> ASSERT(null ps) return []
+ Nothing -> assert (null ps) $ return []
; traceTc "tc_bracket done untyped" (ppr expected_type)
@@ -2013,7 +2014,7 @@ reifyDataCon isGadtDataCon tys dc
-- constructors can be declared infix.
-- See Note [Infix GADT constructors] in GHC.Tc.TyCl.
| dataConIsInfix dc && not isGadtDataCon ->
- ASSERT( r_arg_tys `lengthIs` 2 ) do
+ assert (r_arg_tys `lengthIs` 2) $ do
{ let [r_a1, r_a2] = r_arg_tys
[s1, s2] = dcdBangs
; return $ TH.InfixC (s1,r_a1) name (s2,r_a2) }
@@ -2024,7 +2025,7 @@ reifyDataCon isGadtDataCon tys dc
return $ TH.NormalC name (dcdBangs `zip` r_arg_tys)
; let (ex_tvs', theta') | isGadtDataCon = (g_user_tvs, g_theta)
- | otherwise = ASSERT( all isTyVar ex_tvs )
+ | otherwise = assert (all isTyVar ex_tvs)
-- no covars for haskell syntax
(map mk_specified ex_tvs, theta)
ret_con | null ex_tvs' && null theta' = return main_con
@@ -2032,7 +2033,7 @@ reifyDataCon isGadtDataCon tys dc
{ cxt <- reifyCxt theta'
; ex_tvs'' <- reifyTyVarBndrs ex_tvs'
; return (TH.ForallC ex_tvs'' cxt main_con) }
- ; ASSERT( r_arg_tys `equalLength` dcdBangs )
+ ; assert (r_arg_tys `equalLength` dcdBangs)
ret_con }
where
mk_specified tv = Bndr tv SpecifiedSpec
@@ -2493,7 +2494,7 @@ reifyName thing
-- have free variables, we may need to generate NameL's for them.
where
name = getName thing
- mod = ASSERT( isExternalName name ) nameModule name
+ mod = assert (isExternalName name) $ nameModule name
pkg_str = unitString (moduleUnit mod)
mod_str = moduleNameString (moduleName mod)
occ_str = occNameString occ
@@ -2511,7 +2512,7 @@ reifyFieldLabel fl
| otherwise = TH.mkNameG_v pkg_str mod_str occ_str
where
name = flSelector fl
- mod = ASSERT( isExternalName name ) nameModule name
+ mod = assert (isExternalName name) $ nameModule name
pkg_str = unitString (moduleUnit mod)
mod_str = moduleNameString (moduleName mod)
occ_str = unpackFS (flLabel fl)
diff --git a/compiler/GHC/Tc/Instance/Family.hs b/compiler/GHC/Tc/Instance/Family.hs
index 65e91608b9..ffd2f84f80 100644
--- a/compiler/GHC/Tc/Instance/Family.hs
+++ b/compiler/GHC/Tc/Instance/Family.hs
@@ -49,6 +49,7 @@ import GHC.Types.Var.Set
import GHC.Utils.Outputable
import GHC.Utils.Misc
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import GHC.Utils.FV
import GHC.Data.Bag( Bag, unionBags, unitBag )
@@ -511,7 +512,7 @@ tcLookupDataFamInst_maybe fam_inst_envs tc tc_args
, let rep_tc = dataFamInstRepTyCon rep_fam
co = mkUnbranchedAxInstCo Representational ax rep_args
(mkCoVarCos cvs)
- = ASSERT( null rep_cos ) -- See Note [Constrained family instances] in GHC.Core.FamInstEnv
+ = assert (null rep_cos) $ -- See Note [Constrained family instances] in GHC.Core.FamInstEnv
Just (rep_tc, rep_args, co)
| otherwise
@@ -752,7 +753,7 @@ reportInjectivityErrors
-> [Bool] -- ^ Injectivity annotation
-> TcM ()
reportInjectivityErrors dflags fi_ax axiom inj
- = ASSERT2( any id inj, text "No injective type variables" )
+ = assertPpr (any id inj) (text "No injective type variables") $
do let lhs = coAxBranchLHS axiom
rhs = coAxBranchRHS axiom
fam_tc = coAxiomTyCon fi_ax
diff --git a/compiler/GHC/Tc/Instance/FunDeps.hs b/compiler/GHC/Tc/Instance/FunDeps.hs
index 81cf7524e1..c3bf31fed3 100644
--- a/compiler/GHC/Tc/Instance/FunDeps.hs
+++ b/compiler/GHC/Tc/Instance/FunDeps.hs
@@ -266,9 +266,9 @@ improveClsFD clas_tvs fd
= [] -- Filter out ones that can't possibly match,
| otherwise
- = ASSERT2( equalLength tys_inst tys_actual &&
- equalLength tys_inst clas_tvs
- , ppr tys_inst <+> ppr tys_actual )
+ = assertPpr (equalLength tys_inst tys_actual &&
+ equalLength tys_inst clas_tvs)
+ (ppr tys_inst <+> ppr tys_actual) $
case tcMatchTyKis ltys1 ltys2 of
Nothing -> []
diff --git a/compiler/GHC/Tc/Module.hs b/compiler/GHC/Tc/Module.hs
index fc330061e8..72b588a921 100644
--- a/compiler/GHC/Tc/Module.hs
+++ b/compiler/GHC/Tc/Module.hs
@@ -131,6 +131,7 @@ import GHC.Runtime.Context
import GHC.Utils.Error
import GHC.Utils.Outputable as Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import GHC.Utils.Misc
import GHC.Utils.Logger
@@ -977,7 +978,7 @@ checkBootDeclM is_boot boot_thing real_thing
checkBootDecl :: Bool -> TyThing -> TyThing -> Maybe SDoc
checkBootDecl _ (AnId id1) (AnId id2)
- = ASSERT(id1 == id2)
+ = assert (id1 == id2) $
check (idType id1 `eqType` idType id2)
(text "The two types are different")
@@ -1117,7 +1118,7 @@ checkBootTyCon is_boot tc1 tc2
| Just syn_rhs1 <- synTyConRhs_maybe tc1
, Just syn_rhs2 <- synTyConRhs_maybe tc2
, Just env <- eqVarBndrs emptyRnEnv2 (tyConTyVars tc1) (tyConTyVars tc2)
- = ASSERT(tc1 == tc2)
+ = assert (tc1 == tc2) $
checkRoles roles1 roles2 `andThenCheck`
check (eqTypeX env syn_rhs1 syn_rhs2) empty -- nothing interesting to say
-- This allows abstract 'data T a' to be implemented using 'type T = ...'
@@ -1147,7 +1148,7 @@ checkBootTyCon is_boot tc1 tc2
| Just fam_flav1 <- famTyConFlav_maybe tc1
, Just fam_flav2 <- famTyConFlav_maybe tc2
- = ASSERT(tc1 == tc2)
+ = assert (tc1 == tc2) $
let eqFamFlav OpenSynFamilyTyCon OpenSynFamilyTyCon = True
eqFamFlav (DataFamilyTyCon {}) (DataFamilyTyCon {}) = True
-- This case only happens for hsig merging:
@@ -1173,7 +1174,7 @@ checkBootTyCon is_boot tc1 tc2
| isAlgTyCon tc1 && isAlgTyCon tc2
, Just env <- eqVarBndrs emptyRnEnv2 (tyConTyVars tc1) (tyConTyVars tc2)
- = ASSERT(tc1 == tc2)
+ = assert (tc1 == tc2) $
checkRoles roles1 roles2 `andThenCheck`
check (eqListBy (eqTypeX env)
(tyConStupidTheta tc1) (tyConStupidTheta tc2))
@@ -1282,7 +1283,7 @@ checkBootTyCon is_boot tc1 tc2
`andThenCheck`
-- Don't report roles errors unless the type synonym is nullary
checkUnless (not (null tvs)) $
- ASSERT( null roles2 )
+ assert (null roles2) $
-- If we have something like:
--
-- signature H where
@@ -1825,7 +1826,7 @@ checkMain explicit_mod_hdr export_ies
generateMainBinding tcg_env main_name
| otherwise
- -> ASSERT( null exported_mains )
+ -> assert (null exported_mains) $
-- A fully-checked export list can't contain more
-- than one function with the same OccName
do { complain_no_main dflags main_mod main_occ
@@ -2651,7 +2652,7 @@ tcRnType hsc_env flexi normalise rdr_type
-- Since all the wanteds are equalities, the returned bindings will be empty
; empty_binds <- simplifyTop wanted
- ; MASSERT2( isEmptyBag empty_binds, ppr empty_binds )
+ ; massertPpr (isEmptyBag empty_binds) (ppr empty_binds)
-- Do kind generalisation; see Note [Kind-generalise in tcRnType]
; kvs <- kindGeneralizeAll kind
diff --git a/compiler/GHC/Tc/Solver.hs b/compiler/GHC/Tc/Solver.hs
index 76ce179b9d..373483b5d7 100644
--- a/compiler/GHC/Tc/Solver.hs
+++ b/compiler/GHC/Tc/Solver.hs
@@ -120,7 +120,7 @@ simplifyTopImplic implics
= do { empty_binds <- simplifyTop (mkImplicWC implics)
-- Since all the inputs are implications the returned bindings will be empty
- ; MASSERT2( isEmptyBag empty_binds, ppr empty_binds )
+ ; massertPpr (isEmptyBag empty_binds) (ppr empty_binds)
; return () }
@@ -1932,7 +1932,8 @@ solveImplication imp@(Implic { ic_tclvl = tclvl
-- remaining commented out for now.
{-
check_tc_level = do { cur_lvl <- TcS.getTcLevel
- ; MASSERT2( tclvl == pushTcLevel cur_lvl , text "Cur lvl =" <+> ppr cur_lvl $$ text "Imp lvl =" <+> ppr tclvl ) }
+ ; massertPpr (tclvl == pushTcLevel cur_lvl)
+ (text "Cur lvl =" <+> ppr cur_lvl $$ text "Imp lvl =" <+> ppr tclvl) }
-}
----------------------
@@ -1946,7 +1947,7 @@ setImplicationStatus implic@(Implic { ic_status = status
, ic_info = info
, ic_wanted = wc
, ic_given = givens })
- | ASSERT2( not (isSolvedStatus status ), ppr info )
+ | assertPpr (not (isSolvedStatus status)) (ppr info) $
-- Precondition: we only set the status if it is not already solved
not (isSolvedWC pruned_wc)
= do { traceTcS "setImplicationStatus(not-all-solved) {" (ppr implic)
diff --git a/compiler/GHC/Tc/Solver/Canonical.hs b/compiler/GHC/Tc/Solver/Canonical.hs
index e4020bdfc5..9e47c6ce8d 100644
--- a/compiler/GHC/Tc/Solver/Canonical.hs
+++ b/compiler/GHC/Tc/Solver/Canonical.hs
@@ -39,6 +39,7 @@ import GHC.Types.Var.Env( mkInScopeSet )
import GHC.Types.Var.Set( delVarSetList, anyVarSet )
import GHC.Utils.Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import GHC.Builtin.Types ( anyTypeOfKind )
import GHC.Driver.Session( DynFlags )
import GHC.Types.Name.Set
@@ -208,7 +209,7 @@ canClass :: CtEvidence
canClass ev cls tys pend_sc fds
= -- all classes do *nominal* matching
- ASSERT2( ctEvRole ev == Nominal, ppr ev $$ ppr cls $$ ppr tys )
+ assertPpr (ctEvRole ev == Nominal) (ppr ev $$ ppr cls $$ ppr tys) $
do { (xis, cos) <- rewriteArgsNom ev cls_tc tys
; let co = mkTcTyConAppCo Nominal cls_tc cos
xi = mkClassPred cls xis
@@ -503,8 +504,8 @@ makeSuperClasses cts = concatMapM go cts
go (CDictCan { cc_ev = ev, cc_class = cls, cc_tyargs = tys })
= mkStrictSuperClasses ev [] [] cls tys
go (CQuantCan (QCI { qci_pred = pred, qci_ev = ev }))
- = ASSERT2( isClassPred pred, ppr pred ) -- The cts should all have
- -- class pred heads
+ = assertPpr (isClassPred pred) (ppr pred) $ -- The cts should all have
+ -- class pred heads
mkStrictSuperClasses ev tvs theta cls tys
where
(tvs, theta, cls, tys) = tcSplitDFunTy (ctEvPred ev)
@@ -596,7 +597,7 @@ mk_strict_superclasses rec_clss ev tvs theta cls tys
| otherwise -- Wanted/Derived case, just add Derived superclasses
-- that can lead to improvement.
- = ASSERT2( null tvs && null theta, ppr tvs $$ ppr theta )
+ = assertPpr (null tvs && null theta) (ppr tvs $$ ppr theta) $
concatMapM do_one_derived (immSuperClasses cls tys)
where
loc = ctEvLoc ev
@@ -1214,7 +1215,7 @@ can_eq_nc_forall ev eq_rel s1 s2
-- Done: unify phi1 ~ phi2
go [] subst bndrs2
- = ASSERT( null bndrs2 )
+ = assert (null bndrs2 )
unify loc (eqRelRole eq_rel) phi1' (substTyUnchecked subst phi2)
go _ _ _ = panic "cna_eq_nc_forall" -- case (s:ss) []
@@ -1851,7 +1852,7 @@ canDecomposableTyConAppOK :: CtEvidence -> EqRel
-> TcS (StopOrContinue Ct)
-- Precondition: tys1 and tys2 are the same length, hence "OK"
canDecomposableTyConAppOK ev eq_rel tc tys1 tys2
- = ASSERT( tys1 `equalLength` tys2 )
+ = assert (tys1 `equalLength` tys2) $
do { traceTcS "canDecomposableTyConAppOK"
(ppr ev $$ ppr eq_rel $$ ppr tc $$ ppr tys1 $$ ppr tys2)
; case ev of
@@ -2508,7 +2509,7 @@ instance Outputable CanEqOK where
-- TyEq:H: Checked here.
canEqOK :: DynFlags -> EqRel -> CanEqLHS -> Xi -> CanEqOK
canEqOK dflags eq_rel lhs rhs
- = ASSERT( good_rhs )
+ = assert good_rhs $
case checkTypeEq dflags YesTypeFamilies lhs rhs of
CTE_OK -> CanEqOK
CTE_Bad -> CanEqNotOK OtherCIS
@@ -3037,7 +3038,7 @@ rewriteEvidence ev@(CtWanted { ctev_dest = dest
-- The "_SI" variant ensures that we make a new Wanted
-- with the same shadow-info as the existing one
-- with the same shadow-info as the existing one (#16735)
- ; MASSERT( tcCoercionRole co == ctEvRole ev )
+ ; massert (tcCoercionRole co == ctEvRole ev)
; setWantedEvTerm dest
(mkEvCast (getEvExpr mb_new_ev)
(tcDowngradeRole Representational (ctEvRole ev) co))
diff --git a/compiler/GHC/Tc/Solver/Interact.hs b/compiler/GHC/Tc/Solver/Interact.hs
index ec6e1f9853..9ccdc5bc60 100644
--- a/compiler/GHC/Tc/Solver/Interact.hs
+++ b/compiler/GHC/Tc/Solver/Interact.hs
@@ -33,6 +33,7 @@ import GHC.Core.Unify ( tcUnifyTyWithTFs, ruleMatchTyKiX )
import GHC.Tc.Types.Evidence
import GHC.Utils.Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import GHC.Tc.Types
import GHC.Tc.Types.Constraint
@@ -1065,7 +1066,7 @@ shortCutSolver dflags ev_w ev_i
-- Enabled by the -fsolve-constant-dicts flag
= do { ev_binds_var <- getTcEvBindsVar
- ; ev_binds <- ASSERT2( not (isCoEvBindsVar ev_binds_var ), ppr ev_w )
+ ; ev_binds <- assertPpr (not (isCoEvBindsVar ev_binds_var )) (ppr ev_w) $
getTcEvBindsMap ev_binds_var
; solved_dicts <- getSolvedDicts
@@ -1290,7 +1291,7 @@ improveLocalFunEqs :: CtEvidence -> InertCans -> TyCon -> [TcType] -> TcType
-- See Note [FunDep and implicit parameter reactions]
-- Precondition: isImprovable work_ev
improveLocalFunEqs work_ev inerts fam_tc args rhs
- = ASSERT( isImprovable work_ev )
+ = assert (isImprovable work_ev) $
unless (null improvement_eqns) $
do { traceTcS "interactFunEq improvements: " $
vcat [ text "Eqns:" <+> ppr improvement_eqns
@@ -2471,8 +2472,8 @@ matchLocalInst pred loc
= (match:matches, unif)
| otherwise
- = ASSERT2( disjointVarSet qtv_set (tyCoVarsOfType pred)
- , ppr qci $$ ppr pred )
+ = assertPpr (disjointVarSet qtv_set (tyCoVarsOfType pred))
+ (ppr qci $$ ppr pred)
-- ASSERT: unification relies on the
-- quantified variables being fresh
(matches, unif || this_unif)
diff --git a/compiler/GHC/Tc/Solver/Monad.hs b/compiler/GHC/Tc/Solver/Monad.hs
index c12ffca1eb..cf116996d5 100644
--- a/compiler/GHC/Tc/Solver/Monad.hs
+++ b/compiler/GHC/Tc/Solver/Monad.hs
@@ -2353,7 +2353,7 @@ getPendingGivenScs = do { lvl <- getTcLevel
get_sc_pending :: TcLevel -> InertCans -> ([Ct], InertCans)
get_sc_pending this_lvl ic@(IC { inert_dicts = dicts, inert_insts = insts })
- = ASSERT2( all isGivenCt sc_pending, ppr sc_pending )
+ = assertPpr (all isGivenCt sc_pending) (ppr sc_pending)
-- When getPendingScDics is called,
-- there are never any Wanteds in the inert set
(sc_pending, ic { inert_dicts = dicts', inert_insts = insts' })
@@ -2470,7 +2470,7 @@ isOuterTyVar :: TcLevel -> TyCoVar -> Bool
-- True of a type variable that comes from a
-- shallower level than the ambient level (tclvl)
isOuterTyVar tclvl tv
- | isTyVar tv = ASSERT2( not (isTouchableMetaTyVar tclvl tv), ppr tv <+> ppr tclvl )
+ | isTyVar tv = assertPpr (not (isTouchableMetaTyVar tclvl tv)) (ppr tv <+> ppr tclvl) $
tclvl `strictlyDeeperThan` tcTyVarLevel tv
-- ASSERT: we are dealing with Givens here, and invariant (GivenInv) from
-- Note Note [TcLevel invariants] in GHC.Tc.Utils.TcType ensures that there can't
@@ -3481,7 +3481,7 @@ unifyTyVar :: TcTyVar -> TcType -> TcS ()
--
-- We should never unify the same variable twice!
unifyTyVar tv ty
- = ASSERT2( isMetaTyVar tv, ppr tv )
+ = assertPpr (isMetaTyVar tv) (ppr tv) $
TcS $ \ env ->
do { TcM.traceTc "unifyTyVar" (ppr tv <+> text ":=" <+> ppr ty)
; TcM.writeMetaTyVar tv ty
diff --git a/compiler/GHC/Tc/Solver/Rewrite.hs b/compiler/GHC/Tc/Solver/Rewrite.hs
index 6fd4b85da1..2c95f78f6d 100644
--- a/compiler/GHC/Tc/Solver/Rewrite.hs
+++ b/compiler/GHC/Tc/Solver/Rewrite.hs
@@ -28,6 +28,7 @@ import GHC.Types.Var.Env
import GHC.Driver.Session
import GHC.Utils.Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import GHC.Tc.Solver.Monad as TcS
import GHC.Utils.Misc
@@ -257,7 +258,7 @@ rewriteArgsNom ev tc tys
= do { traceTcS "rewrite_args {" (vcat (map ppr tys))
; (tys', cos, kind_co)
<- runRewriteCtEv ev (rewrite_args_tc tc Nothing tys)
- ; MASSERT( isReflMCo kind_co )
+ ; massert (isReflMCo kind_co)
; traceTcS "rewrite }" (vcat (map ppr tys'))
; return (tys', cos) }
@@ -769,8 +770,8 @@ rewrite_fam_app :: TyCon -> [TcType] -> RewriteM (Xi, Coercion)
-- rewrite_exact_fam_app lifts out the application to top level
-- Postcondition: Coercion :: Xi ~ F tys
rewrite_fam_app tc tys -- Can be over-saturated
- = ASSERT2( tys `lengthAtLeast` tyConArity tc
- , ppr tc $$ ppr (tyConArity tc) $$ ppr tys)
+ = assertPpr (tys `lengthAtLeast` tyConArity tc)
+ (ppr tc $$ ppr (tyConArity tc) $$ ppr tys) $
-- Type functions are saturated
-- The type function might be *over* saturated
@@ -968,7 +969,7 @@ rewrite_tyvar2 tv fr@(_, eq_rel)
ppr rhs_ty $$ ppr ctev)
; let rewrite_co1 = mkSymCo (ctEvCoercion ctev)
rewrite_co = case (ct_eq_rel, eq_rel) of
- (ReprEq, _rel) -> ASSERT( _rel == ReprEq )
+ (ReprEq, _rel) -> assert (_rel == ReprEq )
-- if this ASSERT fails, then
-- eqCanRewriteFR answered incorrectly
rewrite_co1
diff --git a/compiler/GHC/Tc/TyCl.hs b/compiler/GHC/Tc/TyCl.hs
index c645bac3b9..800e240f4e 100644
--- a/compiler/GHC/Tc/TyCl.hs
+++ b/compiler/GHC/Tc/TyCl.hs
@@ -91,6 +91,8 @@ import GHC.Unit
import GHC.Utils.Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
+import GHC.Utils.Constants (debugIsOn)
import GHC.Utils.Misc
import Control.Monad
@@ -1534,7 +1536,7 @@ getFamFlav mb_parent_tycon info =
case info of
DataFamily -> DataFamilyFlavour mb_parent_tycon
OpenTypeFamily -> OpenTypeFamilyFlavour mb_parent_tycon
- ClosedTypeFamily _ -> ASSERT( isNothing mb_parent_tycon ) -- See Note [Closed type family mb_parent_tycon]
+ ClosedTypeFamily _ -> assert (isNothing mb_parent_tycon) -- See Note [Closed type family mb_parent_tycon]
ClosedTypeFamilyFlavour
{- Note [Closed type family mb_parent_tycon]
@@ -2377,7 +2379,7 @@ tcTyClDecl1 parent _roles_info (FamDecl { tcdFam = fd })
tcTyClDecl1 _parent roles_info
(SynDecl { tcdLName = L _ tc_name
, tcdRhs = rhs })
- = ASSERT( isNothing _parent )
+ = assert (isNothing _parent )
fmap noDerivInfos $
tcTySynRhs roles_info tc_name rhs
@@ -2385,7 +2387,7 @@ tcTyClDecl1 _parent roles_info
tcTyClDecl1 _parent roles_info
decl@(DataDecl { tcdLName = L _ tc_name
, tcdDataDefn = defn })
- = ASSERT( isNothing _parent )
+ = assert (isNothing _parent) $
tcDataDefn (tcMkDeclCtxt decl) roles_info tc_name defn
tcTyClDecl1 _parent roles_info
@@ -2396,7 +2398,7 @@ tcTyClDecl1 _parent roles_info
, tcdSigs = sigs
, tcdATs = ats
, tcdATDefs = at_defs })
- = ASSERT( isNothing _parent )
+ = assert (isNothing _parent) $
do { clas <- tcClassDecl1 roles_info class_name hs_ctxt
meths fundeps sigs ats at_defs
; return (noDerivInfos (classTyCon clas)) }
@@ -2550,7 +2552,7 @@ tcDefaultAssocDecl fam_tc
vis_pats = numVisibleArgs hs_pats
-- Kind of family check
- ; ASSERT( fam_tc_name == tc_name )
+ ; assert (fam_tc_name == tc_name) $
checkTc (isTypeFamilyTyCon fam_tc) (wrongKindOfFamily fam_tc)
-- Arity check
@@ -2957,7 +2959,7 @@ tcDataDefn err_ctxt roles_info tc_name
mk_tc_rhs _ tycon data_cons
= case new_or_data of
DataType -> return (mkDataTyConRhs data_cons)
- NewType -> ASSERT( not (null data_cons) )
+ NewType -> assert (not (null data_cons)) $
mkNewTyConRhs tc_name tycon (head data_cons)
@@ -4303,7 +4305,7 @@ checkPartialRecordField all_cons fld
has_field con = fld `elem` (dataConFieldLabels con)
is_exhaustive = all (dataConCannotMatch inst_tys) cons_without_field
- con1 = ASSERT( not (null cons_with_field) ) head cons_with_field
+ con1 = assert (not (null cons_with_field)) $ head cons_with_field
(univ_tvs, _, eq_spec, _, _, _) = dataConFullSig con1
eq_subst = mkTvSubstPrs (map eqSpecPair eq_spec)
inst_tys = substTyVars eq_subst univ_tvs
@@ -4432,12 +4434,12 @@ checkValidDataCon dflags existential_ok tc con
user_tvbs_invariant
= Set.fromList (filterEqSpec eq_spec univs ++ exs)
== Set.fromList user_tvs
- ; MASSERT2( user_tvbs_invariant
- , vcat ([ ppr con
+ ; massertPpr user_tvbs_invariant
+ $ vcat ([ ppr con
, ppr univs
, ppr exs
, ppr eq_spec
- , ppr user_tvs ])) }
+ , ppr user_tvs ]) }
; traceTc "Done validity of data con" $
vcat [ ppr con
@@ -5044,8 +5046,8 @@ addVDQNote :: TcTyCon -> TcM a -> TcM a
-- See Note [Inferring visible dependent quantification]
-- Only types without a signature (CUSK or SAK) here
addVDQNote tycon thing_inside
- | ASSERT2( isTcTyCon tycon, ppr tycon )
- ASSERT2( not (tcTyConIsPoly tycon), ppr tycon $$ ppr tc_kind )
+ | assertPpr (isTcTyCon tycon) (ppr tycon) $
+ assertPpr (not (tcTyConIsPoly tycon)) (ppr tycon $$ ppr tc_kind)
has_vdq
= addLandmarkErrCtxt vdq_warning thing_inside
| otherwise
diff --git a/compiler/GHC/Tc/TyCl/Build.hs b/compiler/GHC/Tc/TyCl/Build.hs
index 1dba4093f1..4e877471bb 100644
--- a/compiler/GHC/Tc/TyCl/Build.hs
+++ b/compiler/GHC/Tc/TyCl/Build.hs
@@ -224,19 +224,19 @@ buildPatSyn src_name declared_infix matcher@(_, matcher_ty,_) builder
pat_ty field_labels
= -- The assertion checks that the matcher is
-- compatible with the pattern synonym
- ASSERT2((and [ univ_tvs `equalLength` univ_tvs1
- , ex_tvs `equalLength` ex_tvs1
- , pat_ty `eqType` substTy subst (scaledThing pat_ty1)
- , prov_theta `eqTypes` substTys subst prov_theta1
- , req_theta `eqTypes` substTys subst req_theta1
- , compareArgTys arg_tys (substTys subst (map scaledThing arg_tys1))
- ])
- , (vcat [ ppr univ_tvs <+> twiddle <+> ppr univ_tvs1
+ assertPpr (and [ univ_tvs `equalLength` univ_tvs1
+ , ex_tvs `equalLength` ex_tvs1
+ , pat_ty `eqType` substTy subst (scaledThing pat_ty1)
+ , prov_theta `eqTypes` substTys subst prov_theta1
+ , req_theta `eqTypes` substTys subst req_theta1
+ , compareArgTys arg_tys (substTys subst (map scaledThing arg_tys1))
+ ])
+ (vcat [ ppr univ_tvs <+> twiddle <+> ppr univ_tvs1
, ppr ex_tvs <+> twiddle <+> ppr ex_tvs1
, ppr pat_ty <+> twiddle <+> ppr pat_ty1
, ppr prov_theta <+> twiddle <+> ppr prov_theta1
, ppr req_theta <+> twiddle <+> ppr req_theta1
- , ppr arg_tys <+> twiddle <+> ppr arg_tys1]))
+ , ppr arg_tys <+> twiddle <+> ppr arg_tys1]) $
mkPatSyn src_name declared_infix
(univ_tvs, req_theta) (ex_tvs, prov_theta)
arg_tys pat_ty
diff --git a/compiler/GHC/Tc/TyCl/Class.hs b/compiler/GHC/Tc/TyCl/Class.hs
index 1c1f6608cd..ea09c89ddb 100644
--- a/compiler/GHC/Tc/TyCl/Class.hs
+++ b/compiler/GHC/Tc/TyCl/Class.hs
@@ -61,6 +61,7 @@ import GHC.Types.Var.Env
import GHC.Types.SourceFile (HscSource(..))
import GHC.Utils.Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import GHC.Types.SrcLoc
import GHC.Core.TyCon
import GHC.Data.Maybe
@@ -369,7 +370,7 @@ instantiateMethod :: Class -> TcId -> [TcType] -> TcType
-- Return the "local method type":
-- forall c. Ix x => (ty2,c) -> ty1
instantiateMethod clas sel_id inst_tys
- = ASSERT( ok_first_pred ) local_meth_ty
+ = assert ok_first_pred local_meth_ty
where
rho_ty = piResultTys (idType sel_id) inst_tys
(first_pred, local_meth_ty) = tcSplitPredFunTy_maybe rho_ty
diff --git a/compiler/GHC/Tc/TyCl/Instance.hs b/compiler/GHC/Tc/TyCl/Instance.hs
index c5be699e13..8a80baaa90 100644
--- a/compiler/GHC/Tc/TyCl/Instance.hs
+++ b/compiler/GHC/Tc/TyCl/Instance.hs
@@ -80,6 +80,7 @@ import GHC.Types.Name
import GHC.Types.Name.Set
import GHC.Utils.Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import GHC.Types.SrcLoc
import GHC.Utils.Misc
import GHC.Data.BooleanFormula ( isUnsatisfied, pprBooleanFormulaNice )
@@ -748,7 +749,7 @@ tcDataFamInstDecl mb_clsinfo tv_skol_env
; axiom_name <- newFamInstAxiomName lfam_name [pats]
; tc_rhs <- case new_or_data of
DataType -> return (mkDataTyConRhs data_cons)
- NewType -> ASSERT( not (null data_cons) )
+ NewType -> assert (not (null data_cons)) $
mkNewTyConRhs rep_tc_name rec_rep_tc (head data_cons)
; let ax_rhs = mkTyConApp rep_tc (mkTyVarTys post_eta_qtvs)
diff --git a/compiler/GHC/Tc/TyCl/PatSyn.hs b/compiler/GHC/Tc/TyCl/PatSyn.hs
index 2ba02e3584..660b0da6da 100644
--- a/compiler/GHC/Tc/TyCl/PatSyn.hs
+++ b/compiler/GHC/Tc/TyCl/PatSyn.hs
@@ -408,7 +408,7 @@ tcCheckPatSynDecl psb@PSB{ psb_id = lname@(L _ name), psb_args = details
-- See Note [Checking against a pattern signature]
; req_dicts <- newEvVars skol_req_theta
; (tclvl, wanted, (lpat', (ex_tvs', prov_dicts, args'))) <-
- ASSERT2( equalLength arg_names arg_tys, ppr name $$ ppr arg_names $$ ppr arg_tys )
+ assertPpr (equalLength arg_names arg_tys) (ppr name $$ ppr arg_names $$ ppr arg_tys) $
pushLevelAndCaptureConstraints $
tcExtendNameTyVarEnv univ_tv_prs $
tcCheckPat PatSyn lpat (unrestricted skol_pat_ty) $
diff --git a/compiler/GHC/Tc/TyCl/Utils.hs b/compiler/GHC/Tc/TyCl/Utils.hs
index efaf909ef8..02c681926f 100644
--- a/compiler/GHC/Tc/TyCl/Utils.hs
+++ b/compiler/GHC/Tc/TyCl/Utils.hs
@@ -55,6 +55,7 @@ import GHC.Core.Coercion ( ltRole )
import GHC.Utils.Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import GHC.Utils.Misc
import GHC.Utils.FV as FV
@@ -715,21 +716,21 @@ runRoleM env thing = (env', update)
setRoleInferenceTc :: Name -> RoleM a -> RoleM a
setRoleInferenceTc name thing = RM $ \m_name vps nvps state ->
- ASSERT( isNothing m_name )
- ASSERT( isEmptyVarEnv vps )
- ASSERT( nvps == 0 )
+ assert (isNothing m_name) $
+ assert (isEmptyVarEnv vps) $
+ assert (nvps == 0) $
unRM thing (Just name) vps nvps state
addRoleInferenceVar :: TyVar -> RoleM a -> RoleM a
addRoleInferenceVar tv thing
= RM $ \m_name vps nvps state ->
- ASSERT( isJust m_name )
+ assert (isJust m_name) $
unRM thing m_name (extendVarEnv vps tv nvps) (nvps+1) state
setRoleInferenceVars :: [TyVar] -> RoleM a -> RoleM a
setRoleInferenceVars tvs thing
= RM $ \m_name _vps _nvps state ->
- ASSERT( isJust m_name )
+ assert (isJust m_name) $
unRM thing m_name (mkVarEnv (zip tvs [0..])) (panic "setRoleInferenceVars")
state
@@ -888,7 +889,7 @@ mkOneRecordSelector all_cons idDetails fl has_sel
-- Find a representative constructor, con1
cons_w_field = conLikesWithFields all_cons [lbl]
- con1 = ASSERT( not (null cons_w_field) ) head cons_w_field
+ con1 = assert (not (null cons_w_field)) $ head cons_w_field
-- Selector type; Note [Polymorphic selectors]
field_ty = conLikeFieldType con1 lbl
diff --git a/compiler/GHC/Tc/Types.hs b/compiler/GHC/Tc/Types.hs
index 8e9e1db1b7..3156a581e8 100644
--- a/compiler/GHC/Tc/Types.hs
+++ b/compiler/GHC/Tc/Types.hs
@@ -1436,7 +1436,7 @@ plusImportAvails
where
plus_mod_dep r1@(GWIB { gwib_mod = m1, gwib_isBoot = boot1 })
r2@(GWIB {gwib_mod = m2, gwib_isBoot = boot2})
- | ASSERT2( m1 == m2, (ppr m1 <+> ppr m2) $$ (ppr (boot1 == IsBoot) <+> ppr (boot2 == IsBoot)))
+ | assertPpr (m1 == m2) ((ppr m1 <+> ppr m2) $$ (ppr (boot1 == IsBoot) <+> ppr (boot2 == IsBoot))) $
boot1 == IsBoot = r2
| otherwise = r1
-- If either side can "see" a non-hi-boot interface, use that
diff --git a/compiler/GHC/Tc/Types/Evidence.hs b/compiler/GHC/Tc/Types/Evidence.hs
index c75760853b..a6dfc4e5f8 100644
--- a/compiler/GHC/Tc/Types/Evidence.hs
+++ b/compiler/GHC/Tc/Types/Evidence.hs
@@ -341,13 +341,13 @@ mkWpFun co1 co2 t1 _ d = WpFun co1 co2 t1 d
mkWpCastR :: TcCoercionR -> HsWrapper
mkWpCastR co
| isTcReflCo co = WpHole
- | otherwise = ASSERT2(tcCoercionRole co == Representational, ppr co)
+ | otherwise = assertPpr (tcCoercionRole co == Representational) (ppr co) $
WpCast co
mkWpCastN :: TcCoercionN -> HsWrapper
mkWpCastN co
| isTcReflCo co = WpHole
- | otherwise = ASSERT2(tcCoercionRole co == Nominal, ppr co)
+ | otherwise = assertPpr (tcCoercionRole co == Nominal) (ppr co) $
WpCast (mkTcSubCo co)
-- The mkTcSubCo converts Nominal to Representational
@@ -866,8 +866,8 @@ Important Details:
mkEvCast :: EvExpr -> TcCoercion -> EvTerm
mkEvCast ev lco
- | ASSERT2( tcCoercionRole lco == Representational
- , (vcat [text "Coercion of wrong role passed to mkEvCast:", ppr ev, ppr lco]))
+ | assertPpr (tcCoercionRole lco == Representational)
+ (vcat [text "Coercion of wrong role passed to mkEvCast:", ppr ev, ppr lco]) $
isTcReflCo lco = EvExpr ev
| otherwise = evCast ev lco
diff --git a/compiler/GHC/Tc/Utils/Backpack.hs b/compiler/GHC/Tc/Utils/Backpack.hs
index a27c4de082..592b3a64ac 100644
--- a/compiler/GHC/Tc/Utils/Backpack.hs
+++ b/compiler/GHC/Tc/Utils/Backpack.hs
@@ -76,10 +76,10 @@ import GHC.Tc.Utils.Env
import GHC.Tc.Errors
import GHC.Tc.Utils.Unify
-import GHC.Utils.Misc
import GHC.Utils.Error
import GHC.Utils.Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import GHC.Data.FastString
import GHC.Data.Maybe
@@ -1060,8 +1060,8 @@ instantiateSignature = do
-- TODO: setup the local RdrEnv so the error messages look a little better.
-- But this information isn't stored anywhere. Should we RETYPECHECK
-- the local one just to get the information? Hmm...
- MASSERT( isHomeModule home_unit outer_mod )
- MASSERT( isHomeUnitInstantiating home_unit)
+ massert (isHomeModule home_unit outer_mod )
+ massert (isHomeUnitInstantiating home_unit)
let uid = Indefinite (homeUnitInstanceOf home_unit)
inner_mod `checkImplements`
Module
diff --git a/compiler/GHC/Tc/Utils/Instantiate.hs b/compiler/GHC/Tc/Utils/Instantiate.hs
index 601cd0a8ea..7edaab0e42 100644
--- a/compiler/GHC/Tc/Utils/Instantiate.hs
+++ b/compiler/GHC/Tc/Utils/Instantiate.hs
@@ -85,6 +85,7 @@ import qualified GHC.LanguageExtensions as LangExt
import GHC.Utils.Misc
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import GHC.Utils.Outputable
import GHC.Unit.State
@@ -124,7 +125,7 @@ newMethodFromName origin name ty_args
; let ty = piResultTys (idType id) ty_args
(theta, _caller_knows_this) = tcSplitPhiTy ty
- ; wrap <- ASSERT( not (isForAllTy ty) && isSingleton theta )
+ ; wrap <- assert (not (isForAllTy ty) && isSingleton theta) $
instCall origin ty_args theta
; return (mkHsWrap wrap (HsVar noExtField (noLocA id))) }
@@ -397,7 +398,7 @@ tcInstInvisibleTyBinder subst (Anon af ty)
| Just (mk, k1, k2) <- get_eq_tys_maybe (substTy subst (scaledThing ty))
-- Equality is the *only* constraint currently handled in types.
-- See Note [Constraints in kinds] in GHC.Core.TyCo.Rep
- = ASSERT( af == InvisArg )
+ = assert (af == InvisArg) $
do { co <- unifyKind Nothing k1 k2
; arg' <- mk co
; return (subst, arg') }
diff --git a/compiler/GHC/Tc/Utils/Monad.hs b/compiler/GHC/Tc/Utils/Monad.hs
index 3243be77de..aea13efbc0 100644
--- a/compiler/GHC/Tc/Utils/Monad.hs
+++ b/compiler/GHC/Tc/Utils/Monad.hs
@@ -188,6 +188,7 @@ import GHC.Data.Maybe
import GHC.Utils.Outputable as Outputable
import GHC.Utils.Error
import GHC.Utils.Panic
+import GHC.Utils.Constants (debugIsOn)
import GHC.Utils.Misc
import GHC.Utils.Logger
diff --git a/compiler/GHC/Tc/Utils/TcMType.hs b/compiler/GHC/Tc/Utils/TcMType.hs
index 8070b4d513..00b16f8380 100644
--- a/compiler/GHC/Tc/Utils/TcMType.hs
+++ b/compiler/GHC/Tc/Utils/TcMType.hs
@@ -127,6 +127,8 @@ import GHC.Types.Name.Env
import GHC.Utils.Misc
import GHC.Utils.Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
+import GHC.Utils.Constants (debugIsOn)
import GHC.Data.FastString
import GHC.Data.Bag
import GHC.Data.Pair
@@ -374,10 +376,10 @@ checkCoercionHole cv co
= do { cv_ty <- zonkTcType (varType cv)
-- co is already zonked, but cv might not be
; return $
- ASSERT2( ok cv_ty
- , (text "Bad coercion hole" <+>
- ppr cv <> colon <+> vcat [ ppr t1, ppr t2, ppr role
- , ppr cv_ty ]) )
+ assertPpr (ok cv_ty)
+ (text "Bad coercion hole" <+>
+ ppr cv <> colon <+> vcat [ ppr t1, ppr t2, ppr role
+ , ppr cv_ty ])
co }
| otherwise
= return co
@@ -906,7 +908,7 @@ newTauTvDetailsAtLevel tclvl
cloneMetaTyVar :: TcTyVar -> TcM TcTyVar
cloneMetaTyVar tv
- = ASSERT( isTcTyVar tv )
+ = assert (isTcTyVar tv) $
do { ref <- newMutVar Flexi
; name' <- cloneMetaTyVarName (tyVarName tv)
; let details' = case tcTyVarDetails tv of
@@ -918,7 +920,7 @@ cloneMetaTyVar tv
-- Works for both type and kind variables
readMetaTyVar :: TyVar -> TcM MetaDetails
-readMetaTyVar tyvar = ASSERT2( isMetaTyVar tyvar, ppr tyvar )
+readMetaTyVar tyvar = assertPpr (isMetaTyVar tyvar) (ppr tyvar) $
readMutVar (metaTyVarRef tyvar)
isFilledMetaTyVar_maybe :: TcTyVar -> TcM (Maybe Type)
@@ -955,15 +957,13 @@ writeMetaTyVar tyvar ty
-- Everything from here on only happens if DEBUG is on
| not (isTcTyVar tyvar)
- = ASSERT2( False, text "Writing to non-tc tyvar" <+> ppr tyvar )
- return ()
+ = massertPpr False (text "Writing to non-tc tyvar" <+> ppr tyvar)
| MetaTv { mtv_ref = ref } <- tcTyVarDetails tyvar
= writeMetaTyVarRef tyvar ref ty
| otherwise
- = ASSERT2( False, text "Writing to non-meta tyvar" <+> ppr tyvar )
- return ()
+ = massertPpr False (text "Writing to non-meta tyvar" <+> ppr tyvar)
--------------------
writeMetaTyVarRef :: TcTyVar -> TcRef MetaDetails -> TcType -> TcM ()
@@ -1000,13 +1000,13 @@ writeMetaTyVarRef tyvar ref ty
; traceTc "writeMetaTyVar" (ppr tyvar <+> text ":=" <+> ppr ty)
-- Check for double updates
- ; MASSERT2( isFlexi meta_details, double_upd_msg meta_details )
+ ; massertPpr (isFlexi meta_details) (double_upd_msg meta_details)
-- Check for level OK
- ; MASSERT2( level_check_ok, level_check_msg )
+ ; massertPpr level_check_ok level_check_msg
-- Check Kinds ok
- ; MASSERT2( kind_check_ok, kind_msg )
+ ; massertPpr kind_check_ok kind_msg
-- Do the write
; writeMutVar ref (Indirect ty) }
@@ -1714,7 +1714,7 @@ quantifyTyVars dvs
-- We should never quantify over coercion variables; check this
; let co_vars = filter isCoVar final_qtvs
- ; MASSERT2( null co_vars, ppr co_vars )
+ ; massertPpr (null co_vars) (ppr co_vars)
; return final_qtvs }
where
@@ -1757,7 +1757,7 @@ zonkAndSkolemise tyvar
; skolemiseQuantifiedTyVar zonked_tyvar }
| otherwise
- = ASSERT2( isImmutableTyVar tyvar || isCoVar tyvar, pprTyVar tyvar )
+ = assertPpr (isImmutableTyVar tyvar || isCoVar tyvar) (pprTyVar tyvar) $
zonkTyCoVarKind tyvar
skolemiseQuantifiedTyVar :: TcTyVar -> TcM TcTyVar
@@ -1869,7 +1869,7 @@ skolemiseUnboundMetaTyVar :: TcTyVar -> TcM TyVar
-- We create a skolem TcTyVar, not a regular TyVar
-- See Note [Zonking to Skolem]
skolemiseUnboundMetaTyVar tv
- = ASSERT2( isMetaTyVar tv, ppr tv )
+ = assertPpr (isMetaTyVar tv) (ppr tv) $
do { when debugIsOn (check_empty tv)
; here <- getSrcSpanM -- Get the location from "here"
-- ie where we are generalising
@@ -2199,7 +2199,7 @@ promoteMetaTyVarTo :: TcLevel -> TcTyVar -> TcM Bool
-- Also returns either the original tyvar (no promotion) or the new one
-- See Note [Promoting unification variables]
promoteMetaTyVarTo tclvl tv
- | ASSERT2( isMetaTyVar tv, ppr tv )
+ | assertPpr (isMetaTyVar tv) (ppr tv) $
tcTyVarLevel tv `strictlyDeeperThan` tclvl
= do { cloned_tv <- cloneMetaTyVar tv
; let rhs_tv = setMetaTyVarTcLevel cloned_tv tclvl
@@ -2240,7 +2240,7 @@ zonkTyCoVar :: TyCoVar -> TcM TcType
-- Works on TyVars and TcTyVars
zonkTyCoVar tv | isTcTyVar tv = zonkTcTyVar tv
| isTyVar tv = mkTyVarTy <$> zonkTyCoVarKind tv
- | otherwise = ASSERT2( isCoVar tv, ppr tv )
+ | otherwise = assertPpr (isCoVar tv) (ppr tv) $
mkCoercionTy . mkCoVarCo <$> zonkTyCoVarKind tv
-- Hackily, when typechecking type and class decls
-- we have TyVars in scope added (only) in
diff --git a/compiler/GHC/Tc/Utils/TcType.hs b/compiler/GHC/Tc/Utils/TcType.hs
index 886d120661..bebc370d39 100644
--- a/compiler/GHC/Tc/Utils/TcType.hs
+++ b/compiler/GHC/Tc/Utils/TcType.hs
@@ -229,6 +229,7 @@ import GHC.Data.Maybe
import GHC.Data.List.SetOps ( getNth, findDupsEq )
import GHC.Utils.Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import GHC.Data.FastString
import GHC.Utils.Error( Validity(..), isValid )
import qualified GHC.LanguageExtensions as LangExt
@@ -698,7 +699,7 @@ instance Outputable TcLevel where
promoteSkolem :: TcLevel -> TcTyVar -> TcTyVar
promoteSkolem tclvl skol
| tclvl < tcTyVarLevel skol
- = ASSERT( isTcTyVar skol && isSkolemTyVar skol )
+ = assert (isTcTyVar skol && isSkolemTyVar skol )
setTcTyVarDetails skol (SkolemTv tclvl (isOverlappableTyVar skol))
| otherwise
@@ -707,7 +708,7 @@ promoteSkolem tclvl skol
-- | Change the TcLevel in a skolem, extending a substitution
promoteSkolemX :: TcLevel -> TCvSubst -> TcTyVar -> (TCvSubst, TcTyVar)
promoteSkolemX tclvl subst skol
- = ASSERT( isTcTyVar skol && isSkolemTyVar skol )
+ = assert (isTcTyVar skol && isSkolemTyVar skol )
(new_subst, new_skol)
where
new_skol
@@ -1005,8 +1006,8 @@ isTouchableMetaTyVar ctxt_tclvl tv
| isTyVar tv -- See Note [Coercion variables in free variable lists]
, MetaTv { mtv_tclvl = tv_tclvl, mtv_info = info } <- tcTyVarDetails tv
, isTouchableInfo info
- = ASSERT2( checkTcLevelInvariant ctxt_tclvl tv_tclvl,
- ppr tv $$ ppr tv_tclvl $$ ppr ctxt_tclvl )
+ = assertPpr (checkTcLevelInvariant ctxt_tclvl tv_tclvl)
+ (ppr tv $$ ppr tv_tclvl $$ ppr ctxt_tclvl) $
tv_tclvl `sameDepthAs` ctxt_tclvl
| otherwise = False
@@ -1028,7 +1029,7 @@ isTyConableTyVar tv
| otherwise = True
isSkolemTyVar tv
- = ASSERT2( tcIsTcTyVar tv, ppr tv )
+ = assertPpr (tcIsTcTyVar tv) (ppr tv) $
case tcTyVarDetails tv of
MetaTv {} -> False
_other -> True
@@ -1220,13 +1221,13 @@ variables. It's up to you to make sure this doesn't matter.
-- Always succeeds, even if it returns an empty list.
tcSplitPiTys :: Type -> ([TyBinder], Type)
tcSplitPiTys ty
- = ASSERT( all isTyBinder (fst sty) ) sty
+ = assert (all isTyBinder (fst sty) ) sty
where sty = splitPiTys ty
-- | Splits a type into a TyBinder and a body, if possible. Panics otherwise
tcSplitPiTy_maybe :: Type -> Maybe (TyBinder, Type)
tcSplitPiTy_maybe ty
- = ASSERT( isMaybeTyBinder sty ) sty
+ = assert (isMaybeTyBinder sty ) sty
where
sty = splitPiTy_maybe ty
isMaybeTyBinder (Just (t,_)) = isTyBinder t
@@ -1234,14 +1235,14 @@ tcSplitPiTy_maybe ty
tcSplitForAllTyVarBinder_maybe :: Type -> Maybe (TyVarBinder, Type)
tcSplitForAllTyVarBinder_maybe ty | Just ty' <- tcView ty = tcSplitForAllTyVarBinder_maybe ty'
-tcSplitForAllTyVarBinder_maybe (ForAllTy tv ty) = ASSERT( isTyVarBinder tv ) Just (tv, ty)
+tcSplitForAllTyVarBinder_maybe (ForAllTy tv ty) = assert (isTyVarBinder tv ) Just (tv, ty)
tcSplitForAllTyVarBinder_maybe _ = Nothing
-- | Like 'tcSplitPiTys', but splits off only named binders,
-- returning just the tyvars.
tcSplitForAllTyVars :: Type -> ([TyVar], Type)
tcSplitForAllTyVars ty
- = ASSERT( all isTyVar (fst sty) ) sty
+ = assert (all isTyVar (fst sty) ) sty
where sty = splitForAllTyCoVars ty
-- | Like 'tcSplitForAllTyVars', but only splits 'ForAllTy's with 'Invisible'
@@ -1265,18 +1266,18 @@ tcSplitSomeForAllTyVars argf_pred ty
-- | Like 'tcSplitForAllTyVars', but only splits 'ForAllTy's with 'Required' type
-- variable binders. All split tyvars are annotated with '()'.
tcSplitForAllReqTVBinders :: Type -> ([TcReqTVBinder], Type)
-tcSplitForAllReqTVBinders ty = ASSERT( all (isTyVar . binderVar) (fst sty) ) sty
+tcSplitForAllReqTVBinders ty = assert (all (isTyVar . binderVar) (fst sty) ) sty
where sty = splitForAllReqTVBinders ty
-- | Like 'tcSplitForAllTyVars', but only splits 'ForAllTy's with 'Invisible' type
-- variable binders. All split tyvars are annotated with their 'Specificity'.
tcSplitForAllInvisTVBinders :: Type -> ([TcInvisTVBinder], Type)
-tcSplitForAllInvisTVBinders ty = ASSERT( all (isTyVar . binderVar) (fst sty) ) sty
+tcSplitForAllInvisTVBinders ty = assert (all (isTyVar . binderVar) (fst sty) ) sty
where sty = splitForAllInvisTVBinders ty
-- | Like 'tcSplitForAllTyVars', but splits off only named binders.
tcSplitForAllTyVarBinders :: Type -> ([TyVarBinder], Type)
-tcSplitForAllTyVarBinders ty = ASSERT( all isTyVarBinder (fst sty)) sty
+tcSplitForAllTyVarBinders ty = assert (all isTyVarBinder (fst sty)) sty
where sty = splitForAllTyCoVarBinders ty
-- | Is this a ForAllTy with a named binder?
diff --git a/compiler/GHC/Tc/Utils/Unify.hs b/compiler/GHC/Tc/Utils/Unify.hs
index eee4e1844c..76d0418eef 100644
--- a/compiler/GHC/Tc/Utils/Unify.hs
+++ b/compiler/GHC/Tc/Utils/Unify.hs
@@ -73,6 +73,7 @@ import GHC.Data.Bag
import GHC.Utils.Misc
import GHC.Utils.Outputable as Outputable
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
import GHC.Exts ( inline )
import Control.Monad
@@ -107,7 +108,7 @@ matchActualFunTySigma
-- and NB: res_ty is an (uninstantiated) SigmaType
matchActualFunTySigma herald mb_thing err_info fun_ty
- = ASSERT2( isRhoTy fun_ty, ppr fun_ty )
+ = assertPpr (isRhoTy fun_ty) (ppr fun_ty) $
go fun_ty
where
-- Does not allocate unnecessary meta variables: if the input already is
@@ -122,7 +123,7 @@ matchActualFunTySigma herald mb_thing err_info fun_ty
go ty | Just ty' <- tcView ty = go ty'
go (FunTy { ft_af = af, ft_mult = w, ft_arg = arg_ty, ft_res = res_ty })
- = ASSERT( af == VisArg )
+ = assert (af == VisArg) $
return (idHsWrapper, Scaled w arg_ty, res_ty)
go ty@(TyVarTy tv)
@@ -323,7 +324,7 @@ matchExpectedFunTys herald ctx arity orig_ty thing_inside
| Just ty' <- tcView ty = go acc_arg_tys n ty'
go acc_arg_tys n (FunTy { ft_mult = mult, ft_af = af, ft_arg = arg_ty, ft_res = res_ty })
- = ASSERT( af == VisArg )
+ = assert (af == VisArg) $
do { (wrap_res, result) <- go ((Scaled mult $ mkCheckExpType arg_ty) : acc_arg_tys)
(n-1) res_ty
; let fun_wrap = mkWpFun idHsWrapper wrap_res (Scaled mult arg_ty) res_ty doc
@@ -419,7 +420,7 @@ matchExpectedTyConApp :: TyCon -- T :: forall kv1 ... kvm. k1 ->
-- Postcondition: (T k1 k2 k3 a b c) is well-kinded
matchExpectedTyConApp tc orig_ty
- = ASSERT(not $ isFunTyCon tc) go orig_ty
+ = assert (not $ isFunTyCon tc) $ go orig_ty
where
go ty
| Just ty' <- tcView ty
@@ -542,7 +543,7 @@ tcWrapResultMono :: HsExpr GhcRn -> HsExpr GhcTc
-- rho-type, so nothing to instantiate; just go straight to unify.
-- It means we don't need to pass in a CtOrigin
tcWrapResultMono rn_expr expr act_ty res_ty
- = ASSERT2( isRhoTy act_ty, ppr act_ty $$ ppr rn_expr )
+ = assertPpr (isRhoTy act_ty) (ppr act_ty $$ ppr rn_expr) $
do { co <- unifyExpectedType rn_expr act_ty res_ty
; return (mkHsWrapCo co expr) }
@@ -1014,7 +1015,7 @@ buildImplicationFor tclvl skol_info skol_tvs given wanted
= return (emptyBag, emptyTcEvBinds)
| otherwise
- = ASSERT2( all (isSkolemTyVar <||> isTyVarTyVar) skol_tvs, ppr skol_tvs )
+ = assertPpr (all (isSkolemTyVar <||> isTyVarTyVar) skol_tvs) (ppr skol_tvs) $
-- Why allow TyVarTvs? Because implicitly declared kind variables in
-- non-CUSK type declarations are TyVarTvs, and we need to bring them
-- into scope as a skolem in an implication. This is OK, though,
@@ -1225,7 +1226,7 @@ uType t_or_k origin orig_ty1 orig_ty2
go (TyConApp tc1 tys1) (TyConApp tc2 tys2)
-- See Note [Mismatched type lists and application decomposition]
| tc1 == tc2, equalLength tys1 tys2
- = ASSERT2( isGenerativeTyCon tc1 Nominal, ppr tc1 )
+ = assertPpr (isGenerativeTyCon tc1 Nominal) (ppr tc1) $
do { cos <- zipWith3M (uType t_or_k) origins' tys1 tys2
; return $ mkTyConAppCo Nominal tc1 cos }
where
@@ -1244,12 +1245,12 @@ uType t_or_k origin orig_ty1 orig_ty2
go (AppTy s1 t1) (TyConApp tc2 ts2)
| Just (ts2', t2') <- snocView ts2
- = ASSERT( not (mustBeSaturated tc2) )
+ = assert (not (mustBeSaturated tc2)) $
go_app (isNextTyConArgVisible tc2 ts2') s1 t1 (TyConApp tc2 ts2') t2'
go (TyConApp tc1 ts1) (AppTy s2 t2)
| Just (ts1', t1') <- snocView ts1
- = ASSERT( not (mustBeSaturated tc1) )
+ = assert (not (mustBeSaturated tc1)) $
go_app (isNextTyConArgVisible tc1 ts1') (TyConApp tc1 ts1') t1' s2 t2
go (CoercionTy co1) (CoercionTy co2)
@@ -1523,7 +1524,7 @@ lhsPriority :: TcTyVar -> Int
-- => more likely to be eliminated
-- See Note [TyVar/TyVar orientation]
lhsPriority tv
- = ASSERT2( isTyVar tv, ppr tv)
+ = assertPpr (isTyVar tv) (ppr tv) $
case tcTyVarDetails tv of
RuntimeUnk -> 0
SkolemTv {} -> 0
diff --git a/compiler/GHC/Tc/Utils/Zonk.hs b/compiler/GHC/Tc/Utils/Zonk.hs
index bca87fb293..e2fe09991f 100644
--- a/compiler/GHC/Tc/Utils/Zonk.hs
+++ b/compiler/GHC/Tc/Utils/Zonk.hs
@@ -73,6 +73,8 @@ import GHC.Core.DataCon
import GHC.Utils.Outputable
import GHC.Utils.Misc
import GHC.Utils.Panic
+import GHC.Utils.Panic.Plain
+import GHC.Utils.Constants (debugIsOn)
import GHC.Core.Multiplicity
import GHC.Core
@@ -506,7 +508,7 @@ zonkTyBndrX :: ZonkEnv -> TcTyVar -> TcM (ZonkEnv, TyVar)
-- as the old one. This important when zonking the
-- TyVarBndrs of a TyCon, whose Names may scope.
zonkTyBndrX env tv
- = ASSERT2( isImmutableTyVar tv, ppr tv <+> dcolon <+> ppr (tyVarKind tv) )
+ = assertPpr (isImmutableTyVar tv) (ppr tv <+> dcolon <+> ppr (tyVarKind tv)) $
do { ki <- zonkTcTypeToTypeX env (tyVarKind tv)
-- Internal names tidy up better, for iface files.
; let tv' = mkTyVar (tyVarName tv) ki
@@ -628,7 +630,7 @@ zonk_bind env (AbsBinds { abs_tvs = tyvars, abs_ev_vars = evs
, abs_exports = exports
, abs_binds = val_binds
, abs_sig = has_sig })
- = ASSERT( all isImmutableTyVar tyvars )
+ = assert (all isImmutableTyVar tyvars) $
do { (env0, new_tyvars) <- zonkTyBndrsX env tyvars
; (env1, new_evs) <- zonkEvBndrsX env0 evs
; (env2, new_ev_binds) <- zonkTcEvBinds_s env1 ev_binds
@@ -792,7 +794,7 @@ zonkLExprs env exprs = mapM (zonkLExpr env) exprs
zonkLExpr env expr = wrapLocMA (zonkExpr env) expr
zonkExpr env (HsVar x (L l id))
- = ASSERT2( isNothing (isDataConId_maybe id), ppr id )
+ = assertPpr (isNothing (isDataConId_maybe id)) (ppr id) $
return (HsVar x (L l (zonkIdOcc env id)))
zonkExpr env (HsUnboundVar her occ)
@@ -1125,7 +1127,7 @@ zonk_cmd_top env (HsCmdTop (CmdTopTc stack_tys ty ids) cmd)
new_ty <- zonkTcTypeToTypeX env ty
new_ids <- mapSndM (zonkExpr env) ids
- MASSERT( isLiftedTypeKind (tcTypeKind new_stack_tys) )
+ massert (isLiftedTypeKind (tcTypeKind new_stack_tys))
-- desugarer assumes that this is not levity polymorphic...
-- but indeed it should always be lifted due to the typing
-- rules for arrows
@@ -1148,7 +1150,7 @@ zonkCoFn env (WpEvLam ev) = do { (env', ev') <- zonkEvBndrX env ev
; return (env', WpEvLam ev') }
zonkCoFn env (WpEvApp arg) = do { arg' <- zonkEvTerm env arg
; return (env, WpEvApp arg') }
-zonkCoFn env (WpTyLam tv) = ASSERT( isImmutableTyVar tv )
+zonkCoFn env (WpTyLam tv) = assert (isImmutableTyVar tv) $
do { (env', tv') <- zonkTyBndrX env tv
; return (env', WpTyLam tv') }
zonkCoFn env (WpTyApp ty) = do { ty' <- zonkTcTypeToTypeX env ty
@@ -1479,7 +1481,7 @@ zonk_pat env p@(ConPat { pat_con = L _ con
, cpt_arg_tys = tys
})
})
- = ASSERT( all isImmutableTyVar tyvars )
+ = assert (all isImmutableTyVar tyvars) $
do { new_tys <- mapM (zonkTcTypeToTypeX env) tys
-- an unboxed tuple pattern (but only an unboxed tuple pattern)
@@ -1626,7 +1628,7 @@ zonkRule env rule@(HsRule { rd_tmvs = tm_bndrs{-::[RuleBndr TcId]-}
zonk_it env v
| isId v = do { v' <- zonkIdBndr env v
; return (extendIdZonkEnvRec env [v'], v') }
- | otherwise = ASSERT( isImmutableTyVar v)
+ | otherwise = assert (isImmutableTyVar v)
zonkTyBndrX env v
-- DV: used to be return (env,v) but that is plain
-- wrong because we may need to go inside the kind
@@ -1960,9 +1962,9 @@ zonkCoHole env hole@(CoercionHole { ch_ref = ref, ch_co_var = cv })
Nothing -> do { traceTc "Zonking unfilled coercion hole" (ppr hole)
; when debugIsOn $
whenNoErrs $
- MASSERT2( False
- , text "Type-correct unfilled coercion hole"
- <+> ppr hole )
+ massertPpr False
+ (text "Type-correct unfilled coercion hole"
+ <+> ppr hole)
; cv' <- zonkCoVar cv
; return $ mkCoVarCo cv' } }
-- This will be an out-of-scope variable, but keeping
diff --git a/compiler/GHC/Tc/Validity.hs b/compiler/GHC/Tc/Validity.hs
index a85158c122..0605926d94 100644
--- a/compiler/GHC/Tc/Validity.hs
+++ b/compiler/GHC/Tc/Validity.hs
@@ -808,7 +808,7 @@ check_syn_tc_app (ve@ValidityEnv{ ve_ctxt = ctxt, ve_expand = expand })
check_args_only expand = mapM_ (check_arg expand) tys
check_expansion_only expand
- = ASSERT2( isTypeSynonymTyCon tc, ppr tc )
+ = assertPpr (isTypeSynonymTyCon tc) (ppr tc) $
case tcView ty of
Just ty' -> let err_ctxt = text "In the expansion of type synonym"
<+> quotes (ppr tc)