diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-08-02 10:50:38 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2020-02-10 12:24:50 -0500 |
commit | 6d1eaf1f5dd5659e7503f10f6a4c2b7ba3ed45f3 (patch) | |
tree | 7c5f296bbc18db24c8b521b11ca0648d251d5891 | |
parent | 8417a30744d1a9f19494840bb69daabba71b6659 (diff) | |
download | haskell-wip/T15211.tar.gz |
Rework closeOverTypeswip/T15211
-rw-r--r-- | compiler/coreSyn/CoreFVs.hs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/coreSyn/CoreFVs.hs b/compiler/coreSyn/CoreFVs.hs index 28a4a9e57a..ff2b82fd87 100644 --- a/compiler/coreSyn/CoreFVs.hs +++ b/compiler/coreSyn/CoreFVs.hs @@ -110,10 +110,7 @@ exprFreeVars = fvVarSet . exprFVs -- Note that this *does* include type variables free in the types of free term -- variables (see #15211). mkExprInScopeSet :: CoreExpr -> InScopeSet -mkExprInScopeSet e = mkInScopeSet $ fvVarSet $ closeOverTypes (exprFreeVarsList e) - -closeOverTypes :: [Var] -> FV -closeOverTypes vars = mapUnionFV (tyCoFVsOfType . varType) vars `unionFV` FV.mkFVs vars +mkExprInScopeSet e = mkInScopeSet $ exprFreeVars e -- | Find all locally-defined free Ids or type variables in an expression -- returning a composable FV computation. See Note [FV naming conventions] in FV @@ -264,7 +261,11 @@ expr_fvs (Type ty) fv_cand in_scope acc = tyCoFVsOfType ty fv_cand in_scope acc expr_fvs (Coercion co) fv_cand in_scope acc = tyCoFVsOfCo co fv_cand in_scope acc -expr_fvs (Var var) fv_cand in_scope acc = FV.unitFV var fv_cand in_scope acc +expr_fvs (Var v) fv_cand in_scope acc@(acc_list, acc_set) + | not (fv_cand v) = acc + | v `elemVarSet` in_scope = acc + | v `elemVarSet` acc_set = acc + | otherwise = tyCoFVsOfType (idType v) fv_cand emptyVarSet (v:acc_list, extendVarSet acc_set v) expr_fvs (Lit _) fv_cand in_scope acc = emptyFV fv_cand in_scope acc expr_fvs (Tick t expr) fv_cand in_scope acc = (tickish_fvs t `unionFV` expr_fvs expr) fv_cand in_scope acc |