summaryrefslogtreecommitdiff
path: root/testsuite/tests/warnings
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2021-02-15 22:36:16 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-03-01 17:30:21 -0500
commit7730713b747e66c93b4fe45478981a6e2ebfc7e2 (patch)
tree64301948eb33d227cfc01aa57be2fdda60a2c13c /testsuite/tests/warnings
parent8c425bd83b3d622cd055ad015daca3539a6670de (diff)
downloadhaskell-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/warnings')
-rw-r--r--testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr43
1 files changed, 10 insertions, 33 deletions
diff --git a/testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr b/testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr
index c2ff69c9ef..a4b6cc0b74 100644
--- a/testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr
+++ b/testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr
@@ -1,50 +1,27 @@
-CaretDiagnostics1.hs:(5,3)-(7,16): error:
+CaretDiagnostics1.hs:7:8-15: error:
• Couldn't match expected type ‘IO a0’ with actual type ‘Int’
- • In a stmt of a 'do' block:
+ • In the second argument of ‘(+)’, namely ‘(3 :: Int)’
+ In a stmt of a 'do' block:
10000000000000000000000000000000000000 + 2 + (3 :: Int)
In the expression:
do 10000000000000000000000000000000000000 + 2 + (3 :: Int)
pure ("this is not an IO" + ())
- In an equation for ‘main’:
- main
- = do 10000000000000000000000000000000000000 + 2 + (3 :: Int)
- pure ("this is not an IO" + ())
- where
- _ = case id of { "γηξ" -> () '0' }
|
-5 | 10000000000000000000000000000000000000 +
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
+7 | (3 :: Int)
+ | ^^^^^^^^
-CaretDiagnostics1.hs:8:3-45: error:
+CaretDiagnostics1.hs:8:9-27: error:
• Couldn't match type ‘[Char]’ with ‘()’
- Expected: IO ()
- Actual: IO String
- • In a stmt of a 'do' block: pure ("this is not an IO" + ())
- In the expression:
- do 10000000000000000000000000000000000000 + 2 + (3 :: Int)
- pure ("this is not an IO" + ())
- In an equation for ‘main’:
- main
- = do 10000000000000000000000000000000000000 + 2 + (3 :: Int)
- pure ("this is not an IO" + ())
- where
- _ = case id of { "γηξ" -> () '0' }
- |
-8 | pure ("this is not an IO" + ( ))
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-CaretDiagnostics1.hs:8:31-44: error:
- • Couldn't match type ‘()’ with ‘[Char]’
- Expected: String
- Actual: ()
- • In the second argument of ‘(+)’, namely ‘()’
+ Expected: ()
+ Actual: String
+ • In the first argument of ‘(+)’, namely ‘"this is not an IO"’
In the first argument of ‘pure’, namely
‘("this is not an IO" + ())’
In a stmt of a 'do' block: pure ("this is not an IO" + ())
|
8 | pure ("this is not an IO" + ( ))
- | ^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^
CaretDiagnostics1.hs:13:7-11: error:
• Couldn't match type: a1 -> a1