You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 6660 Reporter: bvaugon Assigned to:@garrigue Status: acknowledged (set by @garrigue on 2014-12-08T08:30:03Z) Resolution: open Priority: normal Severity: feature Version: 4.02.1 Target version: undecided Category: typing Monitored by:@ygrek@hcarty
Bug description
Considering the following (classical) definition of fail:
# let fail fmt = Printf.ksprintf failwith fmt;;
the following call is wrongly type-checked without any warning:
# fail "error" 123;;
(***)
However, the type-checking of the code:
# (fail "error") 123;;
Warning 20: this argument will not be used by the function.
rightly raises a warning 20 on the argument 123. Thanks to this message,
the programmer understand that he simply forgot a "%d" in his format.
(***)
Remarks that the type-checker behaviour is strange on this kind
of thing, since the code:
# failwith "hahaha" 123;;
Warning 20: this argument will not be used by the function.
rightly raises a warning.
(***)
Since this kind of programming error may happen quickly, it would be
interesting that the warning 20 be raised even when all the arguments
are passed at once (in this kind of configuration).
From a more general point of view, it would be more intuitive that the
OCaml type checker verifies the property: (f x y) is correctly typed iff ((f x) y) is correctly typed
This warning doesn't try to be complete: it couldn't anyway, since there is no way to know whether an argument will really be used or not.
Here the problem is a consequence of the way application works in ocaml. In particular, the property
(f x y) is correctly typed iff ((f x) y) is correctly typed
is actually false, because the type systems handles x and y in a symmetric way in the first case, and an asymmetric way in the second case.
For instance, assuming
let f ?(a=0) x y = a+x+y
then
(f 1 2 ~a:3)
is valid, but
((f 1) 2 ~a:3)
is not.
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.
Original bug ID: 6660
Reporter: bvaugon
Assigned to: @garrigue
Status: acknowledged (set by @garrigue on 2014-12-08T08:30:03Z)
Resolution: open
Priority: normal
Severity: feature
Version: 4.02.1
Target version: undecided
Category: typing
Monitored by: @ygrek @hcarty
Bug description
Considering the following (classical) definition of fail:
the following call is wrongly type-checked without any warning:
(***)
However, the type-checking of the code:
rightly raises a warning 20 on the argument 123. Thanks to this message,
the programmer understand that he simply forgot a "%d" in his format.
(***)
Remarks that the type-checker behaviour is strange on this kind
of thing, since the code:
rightly raises a warning.
(***)
Since this kind of programming error may happen quickly, it would be
interesting that the warning 20 be raised even when all the arguments
are passed at once (in this kind of configuration).
From a more general point of view, it would be more intuitive that the
OCaml type checker verifies the property:
(f x y)
is correctly typed iff((f x) y)
is correctly typedSteps to reproduce
The text was updated successfully, but these errors were encountered: