Unify result type earlier to improve error messages
Ticket #19364 helpfully points out that we do not currently take advantage of pushing the result type of an application into the arguments. This makes error messages notably less good. The fix is rather easy: move the result-type unification step earlier. It's even a bit more efficient; in the the checking case we now do one less zonk. See Note [Unify with expected type before typechecking arguments] in GHC.Tc.Gen.App This change generally improves error messages, but it made one worse: typecheck/should_fail/T16204c. That led me to the realisation that a good error can be replaced by a less-good one, which provoked me to change GHC.Tc.Solver.Interact.inertsCanDischarge. It's explained in the new Note [Combining equalities] One other refactoring: I discovered that KindEqOrigin didn't need a Maybe in its type -- a nice simplification.
Showing
- compiler/GHC/Tc/Errors.hs 7 additions, 10 deletionscompiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Gen/App.hs 97 additions, 67 deletionscompiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/Head.hs 16 additions, 14 deletionscompiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Solver/Interact.hs 81 additions, 22 deletionscompiler/GHC/Tc/Solver/Interact.hs
- compiler/GHC/Tc/Types/Constraint.hs 4 additions, 5 deletionscompiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Types/Origin.hs 7 additions, 9 deletionscompiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Utils/TcMType.hs 5 additions, 8 deletionscompiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/Tc/Utils/Unify.hs 13 additions, 6 deletionscompiler/GHC/Tc/Utils/Unify.hs
- testsuite/tests/gadt/T3169.stderr 5 additions, 8 deletionstestsuite/tests/gadt/T3169.stderr
- testsuite/tests/gadt/rw.stderr 5 additions, 5 deletionstestsuite/tests/gadt/rw.stderr
- testsuite/tests/ghci.debugger/scripts/T14628.stderr 5 additions, 5 deletionstestsuite/tests/ghci.debugger/scripts/T14628.stderr
- testsuite/tests/ghci/scripts/T10508.stderr 6 additions, 9 deletionstestsuite/tests/ghci/scripts/T10508.stderr
- testsuite/tests/indexed-types/should_compile/T12538.stderr 4 additions, 4 deletionstestsuite/tests/indexed-types/should_compile/T12538.stderr
- testsuite/tests/indexed-types/should_fail/T15870.stderr 3 additions, 0 deletionstestsuite/tests/indexed-types/should_fail/T15870.stderr
- testsuite/tests/indexed-types/should_fail/T2544.stderr 18 additions, 5 deletionstestsuite/tests/indexed-types/should_fail/T2544.stderr
- testsuite/tests/indexed-types/should_fail/T2664.stderr 11 additions, 19 deletionstestsuite/tests/indexed-types/should_fail/T2664.stderr
- testsuite/tests/indexed-types/should_fail/T4272.stderr 7 additions, 6 deletionstestsuite/tests/indexed-types/should_fail/T4272.stderr
- testsuite/tests/indexed-types/should_fail/T5439.stderr 2 additions, 1 deletiontestsuite/tests/indexed-types/should_fail/T5439.stderr
- testsuite/tests/indexed-types/should_fail/T9662.stderr 1 addition, 1 deletiontestsuite/tests/indexed-types/should_fail/T9662.stderr
- testsuite/tests/partial-sigs/should_fail/Forall1Bad.stderr 3 additions, 2 deletionstestsuite/tests/partial-sigs/should_fail/Forall1Bad.stderr
Loading
Please register or sign in to comment