-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Inconsistent order when typing constraint patterns #7344
Copy link
Copy link
Closed
Description
Original bug ID: 7344
Reporter: @lpw25
Assigned to: @garrigue
Status: resolved (set by @garrigue on 2017-03-15T01:56:44Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.03.0
Target version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Fixed in version: 4.06.0 +dev/beta1/beta2/rc1
Category: typing
Related to: #7389
Monitored by: @gasche @hcarty
Bug description
The following code does not type-check:
let rec f : unit -> < m: 'a. 'a -> 'a> =
fun () ->
let x = f () in
ignore (x#m 1);
ignore (x#m "hello");
assert false;;
Characters 117-124:
ignore (x#m "hello");
^^^^^^^
Error: This expression has type string but an expression was expected of type
int
but it does if you add parentheses:
let rec (f : unit -> < m: 'a. 'a -> 'a>) =
fun () ->
let x = f () in
ignore (x#m 1);
ignore (x#m "hello");
assert false;;
val f : unit -> < m : 'a. 'a -> 'a > =
or if you add an unused polymorphic variable:
let rec f : 'b. unit -> < m: 'a. 'a -> 'a> =
fun () ->
let x = f () in
ignore (x#m 1);
ignore (x#m "hello");
assert false;;
val f : unit -> < m : 'a. 'a -> 'a > =
or if you turn on -principal:
#principal true;;
let rec f : unit -> < m: 'a. 'a -> 'a> =
fun () ->
let x = f () in
ignore (x#m 1);
ignore (x#m "hello");
assert false;;
val f : unit -> < m : 'a. 'a -> 'a > =
Reactions are currently unavailable