Skip to content

Infinite loop in ghci (only) with the Strict pragma

Summary

The attached simple program, which uses the Strict pragma, loops infinitely in GHCi but works when compiled (with any of the optimization flags -O0, -O1, -O2). It also works in GHCi without the Strict pragma.

Steps to reproduce

Execute the attached haskell source file with ghci or runghc

Expected behavior

I would expect GHCi and the compiled version to behave the same.

In particular, I expect the behaviour experienced when the program is compiled, that is, it finishes and prints the string ParseOk "xyz" ""

Source code

strict_ghci.hs

Environment

  • GHC version used: tried with 8.6.5 and 8.10.2, both behaves the same way.
  • Operating System: MacOS
  • System Architecture: x86-64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information