Commit 17554248 authored by Simon Peyton Jones's avatar Simon Peyton Jones

Fix PmOracle.addVarCoreCt in-scope set

PmOracle.addVarCoreCt was giving a bogus (empty) in-scope set to
exprIsConApp_maybe, which resulted in a substitution-invariant
failure (see MR !1647 discussion).

This patch fixes it, by taking the free vars of the expression.
parent 1b7e1d31
......@@ -585,7 +585,7 @@ getTCvSubst :: Subst -> TCvSubst
getTCvSubst (Subst in_scope _ tenv cenv) = TCvSubst in_scope tenv cenv
-- | See 'Coercion.substCo'
substCo :: Subst -> Coercion -> Coercion
substCo :: HasCallStack => Subst -> Coercion -> Coercion
substCo subst co = Coercion.substCo (getTCvSubst subst) co
{-
......
......@@ -46,6 +46,7 @@ import UniqDFM
import Var (EvVar)
import Name
import CoreSyn
import CoreFVs ( exprFreeVars )
import CoreOpt (exprIsConApp_maybe)
import CoreUtils (exprType)
import MkCore (mkListExpr, mkCharExpr)
......@@ -1670,7 +1671,7 @@ addVarCoreCt delta x e = runMaybeT (execStateT (core_expr x e) delta)
| Just lit <- coreExprAsPmLit e
= pm_lit x lit
| Just (_in_scope, _empty_floats@[], dc, _arg_tys, args)
<- exprIsConApp_maybe empty_in_scope e
<- exprIsConApp_maybe in_scope_env e
= do { arg_ids <- traverse bind_expr args
; data_con_app x dc arg_ids }
-- TODO: Think about how to recognize PatSyns
......@@ -1680,8 +1681,13 @@ addVarCoreCt delta x e = runMaybeT (execStateT (core_expr x e) delta)
-- TODO: Use a CoreMap to identify the CoreExpr with a unique representant
= pure ()
where
empty_in_scope = (emptyInScopeSet, const NoUnfolding)
expr_ty = exprType e
expr_ty = exprType e
expr_in_scope = mkInScopeSet (exprFreeVars e)
in_scope_env = (expr_in_scope, const NoUnfolding)
-- It's inconvenient to get hold of a global in-scope set
-- here, but it'll only be needed if exprIsConApp_maybe ends
-- up substituting inside a forall or lambda (i.e. seldom)
-- so using exprFreeVars seems fine. See MR !1647.
bind_expr :: CoreExpr -> StateT Delta (MaybeT DsM) Id
bind_expr e = do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment