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/Iface/Ext/Ast.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'compiler/GHC/Iface/Ext') diff --git a/compiler/GHC/Iface/Ext/Ast.hs b/compiler/GHC/Iface/Ext/Ast.hs index 692e4a2213..d2e172dbba 100644 --- a/compiler/GHC/Iface/Ext/Ast.hs +++ b/compiler/GHC/Iface/Ext/Ast.hs @@ -57,6 +57,7 @@ import GHC.Types.Var.Env import GHC.Builtin.Uniques import GHC.Iface.Make ( mkIfaceExports ) import GHC.Utils.Panic +import GHC.Utils.Panic.Plain import GHC.Utils.Misc import GHC.Data.Maybe import GHC.Data.FastString @@ -907,7 +908,7 @@ instance HiePass p => ToHie (Located (PatSynBind (GhcPass p) (GhcPass p))) where detSpan = case detScope of LocalScope a -> Just a _ -> Nothing - toBind (PrefixCon ts args) = ASSERT(null ts) PrefixCon ts $ map (C Use) args + toBind (PrefixCon ts args) = assert (null ts) $ PrefixCon ts $ map (C Use) args toBind (InfixCon a b) = InfixCon (C Use a) (C Use b) toBind (RecCon r) = RecCon $ map (PSC detSpan) r -- cgit v1.2.1