Note [Weird special case for SpecDict]
Suppose we are trying to specialise for this this call: $wsplit @T (mkD @k @(a::k) :: C T) where mkD :: forall k (a::k). C T is a top-level dictionary-former. This actually happened in #22459, because of (MP1) of Note [Specialising polymorphic dictionaries]. How can we specialise $wsplit? We might try RULE "SPEC" forall (d :: C T). $wsplit @T d = $s$wsplit but then in the body of $s$wsplit what will we use for the dictionary evidence? We can't use (mkD @k @(a::k)) because k and a aren't in scope. We could zap `k` to (Any @Type) and `a` to (Any @(Any @Type)), but that is a lot of hard work for a very strange case. So we simply refrain from specialising in this case; hence the guard allVarSet (`elemInScopeSet` in_scope) (exprFreeVars d) in the SpecDict cased of specHeader. How did this strange polymorphic mkD arise in the first place? From GHC.Core.Opt.Utils.abstractFloats, which was abstracting over too many type variables. But that too is now fixed; see Note [Which type variables to abstract over] in that module.
References 2
- Which type variables to abstract over GHC.Core.Opt.Simplify.Utils
- Specialising polymorphic dictionaries GHC.Core.Opt.Specialise
Referenced by 2
- Which type variables to abstract over GHC.Core.Opt.Simplify.Utils
- Specialising polymorphic dictionaries GHC.Core.Opt.Specialise