-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Refine error message for erroneous partial application #7221
Copy link
Copy link
Closed
Labels
Description
Original bug ID: 7221
Reporter: @whitequark
Status: acknowledged (set by @damiendoligez on 2017-04-14T14:37:08Z)
Resolution: open
Priority: normal
Severity: feature
Version: 4.03.0+dev / +beta1
Category: typing
Monitored by: @gasche @hcarty
Bug description
Let's look at this case:
# let f a b = ();;
val f : 'a -> 'b -> unit = <fun>
# f 1; ();;
Characters 0-3:
Warning 5: this function application is partial, maybe some arguments are missing.
So far so good. Now let's look at this case:
# let g x = x + 1;;
val g : int -> int = <fun>
# g (f 1);;
Error: This expression has type 'a -> unit but an expression was expected of type int
This isn't too bad too, but this can be much improved by detecting that a partial application was lexically present in a context where a non-function type was inferred, and adding "maybe some arguments are missing" to this one as well.
An additional incentive to fix this is that this class of bug is a very common novice problem, especially for people unaccustomed with currying.
Reactions are currently unavailable