Note [Newtypes can blow the stack]
Suppose we have newtype X = MkX (Int -> X) newtype Y = MkY (Int -> Y) and now wish to prove [W] X ~R Y This Wanted will loop, expanding out the newtypes ever deeper looking for a solid match or a solid discrepancy. Indeed, there is something appropriate to this looping, because X and Y *do* have the same representation, in the limit -- they're both (Fix ((->) Int)). However, no finitely-sized coercion will ever witness it. This loop won't actually cause GHC to hang, though, because we check our depth in `can_eq_newtype_nc`.
References 0
This Note does not link to any other.
Referenced by 2
- Unwrap newtypes first GHC.Tc.Solver.Equality
- GHC.Tc.Solver.Equality call site