Note [Superclass loops]
Suppose we have class C a => D a class D a => C a Then, when we expand superclasses, we'll get back to the self-same predicate, so we have reached a fixpoint in expansion and there is no point in fruitlessly expanding further. This case just falls out from our strategy. Consider f :: C a => a -> Bool f x = x==x Then canDictCt gets the [G] d1: C a constraint, and eager emits superclasses G] d2: D a, [G] d3: C a (psc). (The "psc" means it has its cc_pend_sc has pending expansion fuel.) When processing d3 we find a match with d1 in the inert set, and we always keep the inert item (d1) if possible: see Note [Replacement vs keeping] in GHC.Tc.Solver.InertSet. So d3 dies a quick, happy death.
References 1
- Replacement vs keeping GHC.Tc.Solver.InertSet
Referenced by 1
- Replacement vs keeping GHC.Tc.Solver.InertSet