Panic "StgCmmEnv: variable not found" with ApplicativeDo and ExistentialQuantification
-- Panic.hs
{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE ExistentialQuantification #-}
module Panic where
import Data.STRef
import Control.Monad.ST
data A = forall a. A a
st :: ST s ()
st = do
A _ <- pure $ A True
ref <- newSTRef 1
readSTRef ref
pure ()
$ ghc Panic.hs
[1 of 1] Compiling Panic ( Panic.hs, Panic.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.1.20170106 for x86_64-unknown-linux):
StgCmmEnv: variable not found
$dMonad_aGQ
local binds for:
$trModule
$tcA
$tc'A
$tcA1_rSi
$tc'A1_rSJ
$trModule1_rSK
$trModule2_rSL
sat_sT5
sat_sT9
sat_sTa
Call stack:
CallStack (from HasCallStack):
prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable
callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable
pprPanic, called at compiler/codeGen/StgCmmEnv.hs:137:9 in ghc:StgCmmEnv
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
The above module fails to compile, giving the pasted panic message. Without the ApplicativeDo pragma compilation succeeds. Reproduced with GHC 8.0.2 and a recent head, courtesy of nixpkgs:
gp84vpgar3n3rqvkwj47yyhxvsvbsmi6-ghc-8.1.20170106
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |