Skip to content

ghc-9.4.3: malformed pattern guards cause GHC and GHCi to hang

Summary

Malformed pattern guard expressions cause GHC/i to hang in the middle of the error message, instead of outputting the descriptive error message and returning the user to the REPL/terminal.

Steps to reproduce

Run the following in GHCi, or compile it with GHC:

test x | Just <- x = x

Expected behavior

GHC reports an error relating to how the constructor Just is missing arguments. Earlier versions of GHC (e.g. 9.2.5) do this.

Observed behavior

The interpreter and compiler hang after outputing error:. If you interrupt with Ctrl-C in GHCi, you are returned to the REPL except that (1) the text is gray instead of white, (2) the prelude is not loaded.

ghci> test x | Just <- x = x

<interactive>:1:10: error:

Environment

  • GHC version used: 9.4.3

Optional:

  • Operating System: macOS 13.0.1
  • System Architecture: Apple M1 Pro
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information