
#11371: Bogus in-scope set in substitutions -------------------------------------+------------------------------------- Reporter: simonpj | Owner: niteria Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11360 | Differential Rev(s): phab:D1792, Wiki Page: | phab:D1801, phab:D1802 -------------------------------------+------------------------------------- Comment (by niteria): I have a version that performs as well as the old code on T5030: {{{ piResultTys :: Type -> [Type] -> Type piResultTys ty args = go_fast ty args where go_fast ty [] = ty go_fast (ForAllTy (Anon _) res) (_:args') = go_fast res args' go_fast ty args = go (mkEmptyTCvSubst $ mkInScopeSet $ tyCoVarsOfTypes (ty:args)) ty args -- The free vars of 'ty' and 'args' need to be in scope to satisfy the -- invariant in Note [The substitution invariant] in TyCoRep. go subst ty [] = substTy subst ty go subst ty args | Just ty' <- coreView ty = go subst ty' args go subst (ForAllTy bndr res) (arg:args') = case bndr of Anon _ -> go subst res args' Named tv _ -> go (extendTCvSubst subst tv arg) res args' go subst (TyVarTy tv) args -- Deals with piResultTys (forall a. a) [forall b.b, Int] = go subst (substTyVar subst tv) args -- The previous version used empty_subst here, -- I'm not sure if it matters for correctness go _subst _ty _args = panic "piResultTys" }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11371#comment:44 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler