diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2021-02-15 22:36:16 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-03-01 17:30:21 -0500 |
commit | 7730713b747e66c93b4fe45478981a6e2ebfc7e2 (patch) | |
tree | 64301948eb33d227cfc01aa57be2fdda60a2c13c /testsuite/tests/partial-sigs/should_fail | |
parent | 8c425bd83b3d622cd055ad015daca3539a6670de (diff) | |
download | haskell-7730713b747e66c93b4fe45478981a6e2ebfc7e2.tar.gz |
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.
Diffstat (limited to 'testsuite/tests/partial-sigs/should_fail')
3 files changed, 12 insertions, 10 deletions
diff --git a/testsuite/tests/partial-sigs/should_fail/Forall1Bad.stderr b/testsuite/tests/partial-sigs/should_fail/Forall1Bad.stderr index 26c895ef3c..4a2d167327 100644 --- a/testsuite/tests/partial-sigs/should_fail/Forall1Bad.stderr +++ b/testsuite/tests/partial-sigs/should_fail/Forall1Bad.stderr @@ -1,5 +1,6 @@ -Forall1Bad.hs:9:8: error: +Forall1Bad.hs:9:13: error: • Couldn't match expected type ‘Char’ with actual type ‘Bool’ - • In the expression: fall True + • In the first argument of ‘fall’, namely ‘True’ + In the expression: fall True In an equation for ‘test’: test = fall True diff --git a/testsuite/tests/partial-sigs/should_fail/NamedWildcardExplicitForall.stderr b/testsuite/tests/partial-sigs/should_fail/NamedWildcardExplicitForall.stderr index e366651f7d..17ffbc1595 100644 --- a/testsuite/tests/partial-sigs/should_fail/NamedWildcardExplicitForall.stderr +++ b/testsuite/tests/partial-sigs/should_fail/NamedWildcardExplicitForall.stderr @@ -22,14 +22,14 @@ NamedWildcardExplicitForall.hs:13:26: error: To use the inferred type, enable PartialTypeSignatures • In the type signature: baz :: forall _a. _a -> _b -> (_a, _b) -NamedWildcardExplicitForall.hs:14:16: error: - • Couldn't match expected type ‘Bool’ with actual type ‘_a’ +NamedWildcardExplicitForall.hs:14:12: error: + • Couldn't match expected type ‘_a’ with actual type ‘Bool’ ‘_a’ is a rigid type variable bound by the inferred type of baz :: _a -> Bool -> (_a, Bool) at NamedWildcardExplicitForall.hs:13:15-16 - • In the first argument of ‘not’, namely ‘x’ - In the expression: not x + • In the expression: not x In the expression: (not x, not y) + In an equation for ‘baz’: baz x y = (not x, not y) • Relevant bindings include x :: _a (bound at NamedWildcardExplicitForall.hs:14:5) baz :: _a -> Bool -> (_a, Bool) diff --git a/testsuite/tests/partial-sigs/should_fail/PatBind3.stderr b/testsuite/tests/partial-sigs/should_fail/PatBind3.stderr index e4c368c6e1..a1a1295b12 100644 --- a/testsuite/tests/partial-sigs/should_fail/PatBind3.stderr +++ b/testsuite/tests/partial-sigs/should_fail/PatBind3.stderr @@ -1,9 +1,10 @@ -PatBind3.hs:6:12: error: +PatBind3.hs:6:17: error: • Couldn't match type ‘(Bool, w)’ with ‘Char’ - Expected: Maybe ((Bool, w) -> Char) - Actual: Maybe ((Bool, w) -> (Bool, w)) - • In the expression: Just id + Expected: (Bool, w) -> Char + Actual: (Bool, w) -> (Bool, w) + • In the first argument of ‘Just’, namely ‘id’ + In the expression: Just id In a pattern binding: Just foo = Just id • Relevant bindings include foo :: (Bool, w) -> Char (bound at PatBind3.hs:6:6) |