summaryrefslogtreecommitdiff
path: root/testsuite/tests/typing-poly/pr9603.ml
blob: 02f1e921b9d057f8d74a77bb30c95a81dfd1099e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(* TEST
   * expect
*)

type 'p pair = 'a * 'b constraint 'p = < left:'a; right:'b>

(* New in 4.11 *)
let error: 'left 'right.
  <left:'left; right:'right> pair -> <left:'right; right:'left> pair =
  fun (x,y) -> (y,x)
[%%expect{|
type 'c pair = 'a * 'b constraint 'c = < left : 'a; right : 'b >
val error :
  < left : 'left; right : 'right > pair ->
  < left : 'right; right : 'left > pair = <fun>
|}]

(* Known problem with polymorphic methods *)
let foo :
  < m : 'left 'right. <left:'left; right:'right> pair >
   -> < m : 'left 'right. <left:'left; right:'right> pair >
= fun x -> x

[%%expect{|
Line 4, characters 11-12:
4 | = fun x -> x
               ^
Error: This expression has type
         < m : 'left 'right. < left : 'left; right : 'right > pair >
       but an expression was expected of type
         < m : 'left 'right. < left : 'left; right : 'right > pair >
       Types for method m are incompatible
|}]