summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc/Solver/Rewrite.hs
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/Solver/Rewrite.hs
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/Solver/Rewrite.hs')
-rw-r--r--compiler/GHC/Tc/Solver/Rewrite.hs9
1 files changed, 5 insertions, 4 deletions
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