summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_fail/T13902.stderr
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2017-08-22 09:29:01 -0400
committerRyan Scott <ryan.gl.scott@gmail.com>2017-08-22 09:29:01 -0400
commit8476097609a2044e965157380aeb5d4882a71248 (patch)
tree2e06d4ed4d661d29a52c85d66c44ca0ca4b886b1 /testsuite/tests/typecheck/should_fail/T13902.stderr
parent79b259ae6a0a0c17568d7d03d82e378ad4c4001a (diff)
downloadhaskell-8476097609a2044e965157380aeb5d4882a71248.tar.gz
Revise function arity mismatch errors involving TypeApplications
Summary: Currently, whenever you apply a function to too many arguments and some of those arguments happen to be visible type applications, the error message that GHC gives is rather confusing. Consider the message you receive when typechecking `id @Int 1 2`: ``` The function `id` is applied to three arguments, but its type `Int -> Int` has only one ``` This is baffling, since the two lines treat the visible type argument `@Int` differently. The top line ("applied to three arguments") includes `@Int`, whereas the bottom line ("has only one") excludes `@Int` from consideration. There are multiple ways one could fix this, which I explain in an addendum to `Note [Herald for matchExpectedFunTys]`. The approach adopted here is to change the herald of this error message to include visible type arguments, and to avoid counting them in the "applied to n arguments" part of the error. The end result is that the new error message for `id @Int 1 2` is now: ``` The expression `id @Int` is applied to two arguments, but its type `Int -> Int` has only one ``` Test Plan: make test TEST=T13902 Reviewers: goldfire, austin, bgamari Reviewed By: goldfire Subscribers: rwbarton, thomie GHC Trac Issues: #13902 Differential Revision: https://phabricator.haskell.org/D3868
Diffstat (limited to 'testsuite/tests/typecheck/should_fail/T13902.stderr')
-rw-r--r--testsuite/tests/typecheck/should_fail/T13902.stderr8
1 files changed, 8 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_fail/T13902.stderr b/testsuite/tests/typecheck/should_fail/T13902.stderr
new file mode 100644
index 0000000000..c3d07edfd1
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T13902.stderr
@@ -0,0 +1,8 @@
+
+T13902.hs:8:5: error:
+ • Couldn't match expected type ‘Integer -> Int’
+ with actual type ‘Int’
+ • The expression ‘f @Int’ is applied to two arguments,
+ but its type ‘Int -> Int’ has only one
+ In the expression: f @Int 42 5
+ In an equation for ‘g’: g = f @Int 42 5