Skip to content

Compiler crash with -XStrict and irrefutable match in do statement

While testing GHC 9.0 I encountered the following failure.

ghc: panic! (the 'impossible' happened)
  (GHC version 9.0.0.20201201:
        missing fail op
  Pattern match: ~[commandBuffer_adHZ] is failable, and fail_expr was left unset
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/GHC/Utils/Outputable.hs:1230:37 in ghc:GHC.Utils.Outputable
        pprPanic, called at compiler/GHC/HsToCore/Expr.hs:1151:20 in ghc:GHC.HsToCore.Expr

A minimized reproducer is:

{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Strict #-}

module Hi where

import Control.Monad.IO.Class

newtype F a = F {unF :: IO a }
  deriving ( Functor , Applicative , Monad , MonadIO )

allocateCommandBuffers' :: F [()]
allocateCommandBuffers' = return []
{-# NOINLINE allocateCommandBuffers' #-}

renderFrame :: F ()
renderFrame = do
  ~[commandBuffer] <- allocateCommandBuffers'
  return ()

This is a regression relative to %8.10.2

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