
#13242: Panic "StgCmmEnv: variable not found" with ApplicativeDo and ExistentialQuantification -------------------------------------+------------------------------------- Reporter: ljli | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- {{{#!hs -- 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 }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13242 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler