lookupIdSubst warning
The function lookupIdSubst
lookupIdSubst :: HasDebugCallStack => 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 = warnPprTrace True (text "GHC.Core.Subst.lookupIdSubst" <+> ppr v
$$ ppr in_scope) $
Var v
prints a warning message if it cannot find the variable. Such message is a sign of a bug in GHC - as the Note [Extending the Subst]
says, the in-scope set might contain an updated version of the variable which will be missed.
I've tried building GHC when this warning is replaced by a panic. There's only one problematic call to lookupIdSubst
, in GHC.Core.Rules
. Here's a reproducer, needs -O
:
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)
Since all other calls seem fine, I've created a MR !6302 (closed) with a function lookupIdSubstUnchecked
that is used only in Rules.
The goal of this ticket is to fix the problem in Rules.