From bfabf94f63b6644bd32982fd13ea0c8bca9aeae4 Mon Sep 17 00:00:00 2001 From: Sylvain Henry Date: Thu, 6 May 2021 14:52:53 +0200 Subject: 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 () --- compiler/GHC/Rename/Module.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'compiler/GHC/Rename/Module.hs') diff --git a/compiler/GHC/Rename/Module.hs b/compiler/GHC/Rename/Module.hs index 80384e56d8..1a5fcedf8f 100644 --- a/compiler/GHC/Rename/Module.hs +++ b/compiler/GHC/Rename/Module.hs @@ -58,7 +58,7 @@ import GHC.Types.Basic ( pprRuleName, TypeOrKind(..) ) import GHC.Data.FastString import GHC.Types.SrcLoc as SrcLoc import GHC.Driver.Session -import GHC.Utils.Misc ( debugIsOn, lengthExceeds, partitionWith ) +import GHC.Utils.Misc ( lengthExceeds, partitionWith ) import GHC.Utils.Panic import GHC.Driver.Env ( HscEnv(..), hsc_home_unit) import GHC.Data.List.SetOps ( findDupsEq, removeDups, equivClasses ) @@ -1527,8 +1527,11 @@ rnTyClDecls tycl_ds all_groups = first_group ++ groups - ; MASSERT2( null final_inst_ds, ppr instds_w_fvs $$ ppr inst_ds_map - $$ ppr (flattenSCCs tycl_sccs) $$ ppr final_inst_ds ) + ; massertPpr (null final_inst_ds) + (ppr instds_w_fvs + $$ ppr inst_ds_map + $$ ppr (flattenSCCs tycl_sccs) + $$ ppr final_inst_ds) ; traceRn "rnTycl dependency analysis made groups" (ppr all_groups) ; return (all_groups, all_fvs) } -- cgit v1.2.1