I am using Stack 9.0 as my Haskell build system for my project.
I've just noticed that when I compile my Haskell project with Stack, all assertions are switched off. By contrast while doing "normal" GHC builds at the command-line, assertions are turned on by default unless explicitly switched off with the -fignore-asserts flag (link).
For instance this simple main function fails to throw an assertion error
import Control.Exception.Base
main :: IO ()
main = assert (1==2) $ print "Hello World!"
How do I edit the .cabal file of my project to turn on assertions? Currently inside my .cabal file I see the following ghc options
ghc-options: -threaded -rtsopts -with-rtsopts=-N
which is strange because assertions have not been explicitly turned off within this list.
EDIT:
I have Version 1.1.2 x86_64 hpack-0.14.0 after running stack --version. In particular, I am using stack lts 9.0 with ghc 8.0.2
stack --version? And which ghc? - epsilonhalbe-Oto theghc --makecommand (I've confirmed this on my machine with stack 1.1.3 and cabal 1.24.2.0). As the docs state, this also causes assertions to be turned off. I'm not actually sure why - maybe somebody more knowledgeable will show up and explain it. You can get around it by adding-fno-ignore-assertstoghc-options(or-O0I'm guessing, but that probably would have undesired side-effects). - user2407038-fno-ignore-assertsflag. How do you see the flags used to build a particular executable, so that I can check if assertions are being disabled? - smilingbuddha-v(or-v2or-v3) to theghc-optionsfield. But I've also verified this behaviour (that is,stack build, adding the-fno-ignore-assertsflag and thenstack build) doesn't actually take affect. Evenstack build --reconfigure --force-dirtydoesn't work! I had to delete the.stack-workdirectory. (This one definitely looks like a bug, but keep in mind that stack-1.1.2 and 1.1.3 are very, very outdated) - user2407038