
#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 One position is to say that it should typecheck if the desugaring (according to the paper) is type-correct, which in this case it isn't. And in fact I think that's what happens: {{{ do1.hs:12:8: error: • Couldn't match expected type ‘t0’ with actual type ‘(a -> Int, a)’ because type variable ‘a’ would escape its scope This (rigid, skolem) type variable is bound by a pattern with constructor: A :: forall a. a -> (a -> Int) -> A, in a pattern binding in 'do' block at ado1.hs:12:3-9 • In the pattern: (f1, x1) In the expression: do { p1 <- pure p; A x1 f1 <- pure p1; q1 <- pure q; A x2 f2 <- pure q1; return (f1 x1, f2 x2) } In an equation for ‘st’: st p q = do { p1 <- pure p; A x1 f1 <- pure p1; q1 <- pure q; A x2 f2 <- pure q1; return (f1 x1, f2 x2) } • Relevant bindings include f1 :: a -> Int (bound at ado1.hs:12:8) x1 :: a (bound at ado1.hs:12:5) }}} Arguably we should do something more clever, but at least it's sound. So I'm less worried about this case than the original one which typechecks but generates invalid Core. I'll investigate to see if I can make it typecheck the rhs's separately from the patterns. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13242#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler