Skip to content

`foo !f = id . f` becomes non-strict with -O2

The following program:

foo :: (a -> b) -> a -> b
foo !f = id . f

main :: IO ()
main = print (foo undefined `seq` "ok")

Crashes with Prelude.undefined when compiled without -O2, but prints "ok" with it. As far as I can tell the optimizer shouldn't be allowed to do that.

Trac metadata
Trac field Value
Version 7.6.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information