http://hackage.haskell.org/package/base-4.6.0.1/docs/src/GHC-Base.html#assert seems to define assert
to be a no-op. Where's the logic that turns this into something else when assertions are enabled?
The comment above that function gives a hint:
-- Assertion function. This simply ignores its boolean argument.
-- The compiler may rewrite it to @('assertError' line)@.
So, just use github code search and search for assertError
: search results
This turns up the file RnExpr.lhs. Searching for assert in this file, you'll find the following code:
finishHsVar :: Name -> RnM (HsExpr Name, FreeVars)
-- Separated from rnExpr because it's also used
-- when renaming infix expressions
-- See Note [Adding the implicit parameter to 'assert']
finishHsVar name
= do { this_mod <- getModule
; when (nameIsLocalOrFrom this_mod name) $
checkThLocalName name
; ignore_asserts <- goptM Opt_IgnoreAsserts
; if ignore_asserts || not (name `hasKey` assertIdKey)
then return (HsVar name, unitFV name)
else do { e <- mkAssertErrorExpr
; return (e, unitFV name) } }
That's where it replaces assert
by assertError
, but only if assertions are enabled.
assertError
is defined in GHC.IO.Exception
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With