From 7c0bfc36a39ab8e181cca97be3e5b21dda9be0cb Mon Sep 17 00:00:00 2001 From: "simonpj@microsoft.com" Date: Sun, 14 Sep 2008 11:34:34 +0000 Subject: [PATCH] Fix Trac #2587: take account of type lets GHC allows a non-recursive let for type varaibles let a = TYPE ty in ... But the free-variable finder had not caught up with this fact. This patch catches up. --- compiler/coreSyn/CoreFVs.lhs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/coreSyn/CoreFVs.lhs b/compiler/coreSyn/CoreFVs.lhs index dedc4c0..d2d1383 100644 --- a/compiler/coreSyn/CoreFVs.lhs +++ b/compiler/coreSyn/CoreFVs.lhs @@ -194,7 +194,7 @@ expr_fvs (Let (Rec pairs) body) --------- rhs_fvs :: (Id,CoreExpr) -> FV -rhs_fvs (bndr, rhs) = expr_fvs rhs `union` someVars (idRuleVars bndr) +rhs_fvs (bndr, rhs) = expr_fvs rhs `union` someVars (bndrRuleVars bndr) -- Treat any RULES as extra RHSs of the binding --------- @@ -373,6 +373,10 @@ varTypeTyVars var idFreeVars :: Id -> VarSet idFreeVars id = ASSERT( isId id) idRuleVars id `unionVarSet` varTypeTyVars id +bndrRuleVars ::Var -> VarSet +bndrRuleVars v | isTyVar v = emptyVarSet + | otherwise = idRuleVars v + idRuleVars ::Id -> VarSet idRuleVars id = ASSERT( isId id) specInfoFreeVars (idSpecialisation id) \end{code} @@ -425,7 +429,7 @@ freeVars (Case scrut bndr ty alts) rhs2 = freeVars rhs freeVars (Let (NonRec binder rhs) body) - = (freeVarsOf rhs2 `unionFVs` body_fvs `unionFVs` idRuleVars binder, + = (freeVarsOf rhs2 `unionFVs` body_fvs `unionFVs` bndrRuleVars binder, -- Remember any rules; cf rhs_fvs above AnnLet (AnnNonRec binder rhs2) body2) where -- 1.7.10.4