summaryrefslogtreecommitdiff
path: root/compiler/GHC/Core/Subst.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC/Core/Subst.hs')
-rw-r--r--compiler/GHC/Core/Subst.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/GHC/Core/Subst.hs b/compiler/GHC/Core/Subst.hs
index 36f3bad0d4..7e0c0ef8f4 100644
--- a/compiler/GHC/Core/Subst.hs
+++ b/compiler/GHC/Core/Subst.hs
@@ -18,6 +18,7 @@ module GHC.Core.Subst (
substTy, substCo, substExpr, substExprSC, substBind, substBindSC,
substUnfolding, substUnfoldingSC,
lookupIdSubst, lookupTCvSubst, substIdType, substIdOcc,
+ lookupIdSubstUnchecked,
substTickish, substDVarSet, substIdInfo,
-- ** Operations on substitutions
@@ -250,12 +251,21 @@ extendSubstList subst [] = subst
extendSubstList subst ((var,rhs):prs) = extendSubstList (extendSubst subst var rhs) prs
-- | Find the substitution for an 'Id' in the 'Subst'
-lookupIdSubst :: HasDebugCallStack => Subst -> Id -> CoreExpr
+lookupIdSubst :: HasCallStack => Subst -> Id -> CoreExpr
lookupIdSubst (Subst in_scope ids _ _) v
| not (isLocalId v) = Var v
| Just e <- lookupVarEnv ids v = e
| Just v' <- lookupInScope in_scope v = Var v'
-- Vital! See Note [Extending the Subst]
+ | otherwise = pprPanic "lookupIdSubst" (ppr v $$ ppr in_scope)
+
+-- | Find the substitution for an 'Id' in the 'Subst'
+lookupIdSubstUnchecked :: HasDebugCallStack => Subst -> Id -> CoreExpr
+lookupIdSubstUnchecked (Subst in_scope ids _ _) v
+ | not (isLocalId v) = Var v
+ | Just e <- lookupVarEnv ids v = e
+ | Just v' <- lookupInScope in_scope v = Var v'
+ -- Vital! See Note [Extending the Subst]
| otherwise = warnPprTrace True (text "GHC.Core.Subst.lookupIdSubst" <+> ppr v
$$ ppr in_scope) $
Var v