[GHC] #13902: Misleading function arity mismatch error with TypeApplications
GHC
ghc-devs at haskell.org
Tue Aug 22 14:56:18 UTC 2017
#13902: Misleading function arity mismatch error with TypeApplications
-------------------------------------+-------------------------------------
Reporter: RyanGlScott | Owner: (none)
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Compiler (Type | Version: 8.0.1
checker) | Keywords:
Resolution: | TypeApplications
Operating System: Unknown/Multiple | Architecture:
Type of failure: Poor/confusing | Unknown/Multiple
error message | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D3868
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ryan Scott <ryan.gl.scott@…>):
In [changeset:"8476097609a2044e965157380aeb5d4882a71248/ghc"
84760976/ghc]:
{{{
#!CommitTicketReference repository="ghc"
revision="8476097609a2044e965157380aeb5d4882a71248"
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
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13902#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list