
#13242: Panic "StgCmmEnv: variable not found" with ApplicativeDo and ExistentialQuantification -------------------------------------+------------------------------------- Reporter: ljli | Owner: simonmar Type: bug | Status: new Priority: highest | Milestone: 8.0.3 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonmar): @simonpj I've investigated this and run into something I don't understand, can you help? When we typecheck the above program without `ApplicativeDo` we get {{{ AbsBindsSig [] [] {Exported type: st :: IO () [LclId] Bind: st_aNk = do A{a_aNN EvBinds{[W] $dMonad_aNP = $dMonad_aNw [W] $dMonad_aNU = $dMonad_aNw [W] $dMonad_aZe = $dMonad_aNw [W] $dNum_aZc = GHC.Num.$fNumInteger @[] []}} _ <- pure @ IO $dApplicative_aNK @ A (A @ Bool True) x_aCp <- return @ IO $dMonad_aNU @ Integer 1 return @ IO $dMonad_aZe @ () () Evidence: EvBinds{}} }}} Note that `$dMonad_aNU`, used in the second statement, is bound by the `EvBinds` in the (existential) pattern in the first statement. ApplicativeDo isn't expecting there to be any dependencies between the two patterns, which is why it produces invalid Core. I don't understand why we're putting these dict bindings in the first pattern, they don't seem to relate to the existential type. I could just disable ApplicativeDo for existential patterns, but if that's necessary I'd like to understand why. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13242#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler