summaryrefslogtreecommitdiff
path: root/compiler/GHC/Core/Subst.hs
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2021-08-03 17:23:49 +0200
committerKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2021-08-03 17:32:57 +0200
commit32a1e8c43c9e89392c62b1f7f2e61136176afe7a (patch)
treeb637dc15a4aea85cf897b6f6b222a7d04c1a5489 /compiler/GHC/Core/Subst.hs
parent34e352173dd1fc3cd86c49380fda5a4eb5dd7aef (diff)
downloadhaskell-wip/more-panics.tar.gz
Convert warnings to panicswip/more-panics
This minimized module compiled with -O triggers the problem in GHC.Core.Rules: module GHC.Utils.TmpFs where import qualified Data.Map as Map cleanTempDirs :: ([String] -> a) -> Map.Map String String -> a cleanTempDirs logger ds = logger (Map.elems ds)
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