Track rewriter sets more accurately in constraint solving
The key change, which fixed #25440, is to call `recordRewriter` in GHC.Tc.Solver.Rewrite.rewrite_exact_fam_app. This missing call meant that we were secretly rewriting a Wanted with a Wanted, but not really noticing; and that led to a very bad error message, as you can see in the ticket. But of course that led me into rabbit hole of other refactoring around the RewriteSet code: * Improve Notes [Wanteds rewrite Wanteds] * Zonk the RewriterSet in `zonkCtEvidence` rather than only in GHC.Tc.Errors. This is tidier anyway (e.g. de-clutters debug output), and helps with the next point. * In GHC.Tc.Solver.Equality.inertsCanDischarge, don't replace a constraint with no rewriters with an equal constraint that has many. See See (CE4) in Note [Combining equalities] * Move zonkRewriterSet and friends from GHC.Tc.Zonk.Type into GHC.Tc.Zonk.TcType, where they properly belong. A handful of tests get better error messages. For some reason T24984 gets 12% less compiler allocation -- good Metric Decrease: T24984
Showing
- compiler/GHC/Core/Coercion.hs 6 additions, 5 deletionscompiler/GHC/Core/Coercion.hs
- compiler/GHC/Tc/Errors.hs 8 additions, 9 deletionscompiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Solver/Default.hs 3 additions, 3 deletionscompiler/GHC/Tc/Solver/Default.hs
- compiler/GHC/Tc/Solver/Equality.hs 112 additions, 57 deletionscompiler/GHC/Tc/Solver/Equality.hs
- compiler/GHC/Tc/Solver/Monad.hs 16 additions, 15 deletionscompiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/Solver/Rewrite.hs 17 additions, 15 deletionscompiler/GHC/Tc/Solver/Rewrite.hs
- compiler/GHC/Tc/Types/Constraint.hs 49 additions, 19 deletionscompiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Utils/TcMType.hs 2 additions, 3 deletionscompiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/Tc/Utils/Unify.hs 4 additions, 3 deletionscompiler/GHC/Tc/Utils/Unify.hs
- compiler/GHC/Tc/Zonk/TcType.hs 121 additions, 6 deletionscompiler/GHC/Tc/Zonk/TcType.hs
- compiler/GHC/Tc/Zonk/Type.hs 0 additions, 95 deletionscompiler/GHC/Tc/Zonk/Type.hs
- testsuite/tests/indexed-types/should_fail/T3330c.stderr 19 additions, 11 deletionstestsuite/tests/indexed-types/should_fail/T3330c.stderr
- testsuite/tests/indexed-types/should_fail/T4174.stderr 14 additions, 4 deletionstestsuite/tests/indexed-types/should_fail/T4174.stderr
- testsuite/tests/indexed-types/should_fail/T8227.stderr 0 additions, 9 deletionstestsuite/tests/indexed-types/should_fail/T8227.stderr
- testsuite/tests/typecheck/should_compile/T25266a.stderr 5 additions, 5 deletionstestsuite/tests/typecheck/should_compile/T25266a.stderr
- testsuite/tests/typecheck/should_fail/T18851.stderr 3 additions, 3 deletionstestsuite/tests/typecheck/should_fail/T18851.stderr
Loading
Please register or sign in to comment