Expose `-fignore-asserts` as the CPP macro `__GLASGOW_HASKELL_ASSERTS_IGNORED__`
Control.Exception.assert
allows the user to do assertions in development which disappear when compiled with optimizations enabled.
However, Control.Exception.assert
always throws an AssertFailed
exception. There are cases in which a user might want to do other kinds of assertions: Either throwing a different kind of exception, or maybe different logic (that is not related to exceptions) all-together.
This MR exposes whether the fignore-asserts
flag is enabled (either directly or by using -O1
/-O2
without also specifying -fno-ignore-asserts
) as the CPP macro __GLASGOW_HASKELL_ASSERTS_IGNORED__
, therefore giving users a very straightforward way to define custom assert-like functionality.
This particular design was chosen in collaboration with @bgamari.
Fixes #24967 (closed)
Where is the key part of this patch? That is, what should reviewers look at first?
The only code of this MR is in GHC.SysTools.Cpp.hs
.
Please take a few moments to address the following points:
-
if your MR may break existing programs (e.g. touches base
or causes the compiler to reject programs), please describe the expected breakage and add the user-facing label. This will run ghc/head.hackage> to characterise the effect of your change on Hackage. -
ensure that your commits are either individually buildable or squashed -
ensure that your commit messages describe what they do (referring to tickets using #NNNN
syntax when appropriate) -
have added source comments describing your change. For larger changes you likely should add a Note and cross-reference it from the relevant places. -
add a testcase to the testsuite. -
updates the users guide if applicable -
mentions new features in the release notes for the next release
If you have any questions don't hesitate to open your merge request and inquire
in a comment. If your patch isn't quite done yet please do add prefix your MR
title with WIP:
.
By default a minimal validation pipeline is run on each merge request, the full-ci label can be applied to perform additional validation checks if your MR affects a more unusual configuration.
Once your change is ready please remove the WIP:
tag and wait for review. If
no one has offered a review in a few days then please leave a comment mentioning
@triagers and apply the Blocked on Review label.