diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2021-05-06 14:52:53 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-05-12 21:41:43 -0400 |
commit | bfabf94f63b6644bd32982fd13ea0c8bca9aeae4 (patch) | |
tree | b185749a9676a57c226dab9681fa3c4ba0415dd3 /compiler/GHC/Data/StringBuffer.hs | |
parent | da56ed41b62ab132db6d62637c11076985410b24 (diff) | |
download | haskell-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/Data/StringBuffer.hs')
-rw-r--r-- | compiler/GHC/Data/StringBuffer.hs | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/compiler/GHC/Data/StringBuffer.hs b/compiler/GHC/Data/StringBuffer.hs index 0de4b007ba..0932397ae5 100644 --- a/compiler/GHC/Data/StringBuffer.hs +++ b/compiler/GHC/Data/StringBuffer.hs @@ -56,7 +56,6 @@ import GHC.Data.FastString import GHC.Utils.Encoding import GHC.Utils.IO.Unsafe import GHC.Utils.Panic.Plain -import GHC.Utils.Misc import GHC.Utils.Exception ( bracket_ ) import Data.Maybe @@ -150,7 +149,7 @@ skipBOM h size offset = if size > 0 && offset == 0 then do -- Validate assumption that handle is in binary mode. - ASSERTM( hGetEncoding h >>= return . isNothing ) + assertM (hGetEncoding h >>= return . isNothing) -- Temporarily select utf8 encoding with error ignoring, -- to make `hLookAhead` and `hGetChar` return full Unicode characters. bracket_ (hSetEncoding h safeEncoding) (hSetBinaryMode h True) $ do |