summaryrefslogtreecommitdiff
path: root/compiler/GHC/Iface/Rename.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/Iface/Rename.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/Iface/Rename.hs')
-rw-r--r--compiler/GHC/Iface/Rename.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/GHC/Iface/Rename.hs b/compiler/GHC/Iface/Rename.hs
index 500e12a1db..2df946529a 100644
--- a/compiler/GHC/Iface/Rename.hs
+++ b/compiler/GHC/Iface/Rename.hs
@@ -251,7 +251,8 @@ rnAvailInfo (AvailTC n ns) = do
ns' <- mapM rnGreName ns
case ns' of
[] -> panic "rnAvailInfoEmpty AvailInfo"
- (rep:rest) -> ASSERT2( all ((== childModule rep) . childModule) rest, ppr rep $$ hcat (map ppr rest) ) do
+ (rep:rest) -> assertPpr (all ((== childModule rep) . childModule) rest)
+ (ppr rep $$ hcat (map ppr rest)) $ do
n' <- setNameModule (Just (childModule rep)) n
return (AvailTC n' ns')
where
@@ -376,7 +377,7 @@ rnIfaceNeverExported name = do
iface_semantic_mod <- fmap sh_if_semantic_module getGblEnv
let m = renameHoleModule unit_state hmap $ nameModule name
-- Doublecheck that this DFun/coercion axiom was, indeed, locally defined.
- MASSERT2( iface_semantic_mod == m, ppr iface_semantic_mod <+> ppr m )
+ massertPpr (iface_semantic_mod == m) (ppr iface_semantic_mod <+> ppr m)
setNameModule (Just m) name
-- Note [rnIfaceNeverExported]