Fix isDroppableCt (Trac #14763)
When finishing up an implication constraint, it's a bit tricky to decide which Derived constraints to retain (for error reporting) and which to discard. I got this wrong in commit f20cf982 (Remove wc_insol from WantedConstraints) The particular problem in Trac #14763 was that we were reporting as an error a fundep-generated constraint (ex ~ T) where 'ex' is an existentially-bound variable in a pattern match. But this isn't really an error at all. This patch fixes the problem. Indeed, since I had to understand this rather tricky code, I took the opportunity to clean it up and document better. See isDroppableCt :: Ct -> Bool and Note [Dropping derived constraints] I also removed wl_deriv altogether from the WorkList data type. It was there in the hope of gaining efficiency by not even processing lots of derived constraints, but it has turned out that most derived constraints (notably equalities) must be processed anyway; see Note [Prioritise equalities] in TcSMonad. The two are coupled because to decide which constraints to put in wl_deriv I was using another variant of isDroppableCt. Now it's much simpler -- and perhaps even more efficient too.
Showing
- compiler/typecheck/TcCanonical.hs 10 additions, 5 deletionscompiler/typecheck/TcCanonical.hs
- compiler/typecheck/TcErrors.hs 1 addition, 1 deletioncompiler/typecheck/TcErrors.hs
- compiler/typecheck/TcInteract.hs 3 additions, 2 deletionscompiler/typecheck/TcInteract.hs
- compiler/typecheck/TcRnTypes.hs 66 additions, 43 deletionscompiler/typecheck/TcRnTypes.hs
- compiler/typecheck/TcSMonad.hs 33 additions, 76 deletionscompiler/typecheck/TcSMonad.hs
- testsuite/tests/typecheck/should_compile/T14763.hs 34 additions, 0 deletionstestsuite/tests/typecheck/should_compile/T14763.hs
- testsuite/tests/typecheck/should_compile/all.T 1 addition, 0 deletionstestsuite/tests/typecheck/should_compile/all.T
Loading
Please register or sign in to comment