blob: 91c8ea77eb7154edd335033339ece5d4fe0bc249 (
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
34
|
(* TEST
* expect
*)
type 'self nat =
| Z
| S of 'self
;;
[%%expect{|
type 'self nat = Z | S of 'self
|}]
(* without rectypes: rejected *)
external cast : int -> 'self nat as 'self = "%identity"
;;
[%%expect{|
Line 1, characters 16-41:
1 | external cast : int -> 'self nat as 'self = "%identity"
^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This alias is bound to type int -> 'a nat
but is used as an instance of type 'a
The type variable 'a occurs inside int -> 'a nat
|}]
#rectypes;;
(* with rectypes: accepted (used to crash) *)
external cast : int -> 'self nat as 'self = "%identity"
;;
[%%expect{|
external cast : int -> 'a nat as 'a = "%identity"
|}]
|