Skip to content

Arrows case expression and EmptyCase are incompatible

Summary

When one enables the EmptyCase extension, uses the case syntax in arrow syntax, and enters zero cases, the compiler crashes.

Steps to reproduce

{-# LANGUAGE Arrows #-}
{-# LANGUAGE EmptyCase #-}

import Data.Void

main = return ()

foo :: Void -> a
foo = proc void -> do
  case void of
[1 of 1] Compiling Main             ( EmptyCaseBug.hs, EmptyCaseBug.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 9.0.2:
        foldb of empty list
CallStack (from HasCallStack):
  error, called at compiler/GHC/HsToCore/Arrows.hs:1201:14 in ghc:GHC.HsToCore.Arrows

Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug

Expected behavior

No compiler crash, in fact a valid program.

Environment

  • GHC version used: 9.0.2, 9.2.4

It seems to be fixed on 9.4, I'm not sure. If yes, feel free to close, I couldn't find the issue.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information