Note [Don't add HasCallStack constraints to the solved set]
We must not add solved Wanted dictionaries that mention HasCallStack constraints to the solved set, or we might fail to accumulate the proper call stack, as was reported in #25529. Recall that HasCallStack constraints (and the related HasExceptionContext constraints) are implicit parameter constraints, and are accumulated as per Note [Overview of implicit CallStacks] in GHC.Tc.Types.Evidence. When we solve a Wanted that contains a HasCallStack constraint, we don't want to cache the result, because re-using that solution means re-using the call-stack in a different context! See also Note [Shadowing of implicit parameters], which deals with a similar problem with Given implicit parameter constraints.
References 2
- Shadowing of implicit parameters GHC.Tc.Solver.Dict
- Overview of implicit CallStacks GHC.Tc.Types.Evidence
Referenced by 2
- GHC.Tc.Solver.Monad call site
- Using isCallStackTy in mightMentionIP GHC.Tc.Solver.Monad