summaryrefslogtreecommitdiff
path: root/testsuite/tests/typing-misc/unbound_type_variables.ml
blob: c00d03607964a28b8d01f2b385f0337de9faad5a (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
(* TEST
   * expect
*)

type synonym = 'a -> 'a

[%%expect{|
Line 1, characters 15-17:
1 | type synonym = 'a -> 'a
                   ^^
Error: The type variable 'a is unbound in this type declaration.
|}]

type record = { contents: 'a }

[%%expect{|
Line 1, characters 26-28:
1 | type record = { contents: 'a }
                              ^^
Error: The type variable 'a is unbound in this type declaration.
|}]

type wrapper = Wrapper of 'a

[%%expect{|
Line 1, characters 26-28:
1 | type wrapper = Wrapper of 'a
                              ^^
Error: The type variable 'a is unbound in this type declaration.
|}]

(* This type secretly has a type variable in it *)
type polyvariant = [> `C]

[%%expect{|
Line 1, characters 0-25:
1 | type polyvariant = [> `C]
    ^^^^^^^^^^^^^^^^^^^^^^^^^
Error: A type variable is unbound in this type declaration.
       In type [> `C ] as 'a the variable 'a is unbound
|}]

type 'a only_one = 'a * 'b

[%%expect{|
Line 1, characters 24-26:
1 | type 'a only_one = 'a * 'b
                            ^^
Error: The type variable 'b is unbound in this type declaration.
|}]

type extensible = ..
type extensible += Extension of 'a

[%%expect{|
type extensible = ..
Line 2, characters 32-34:
2 | type extensible += Extension of 'a
                                    ^^
Error: The type variable 'a is unbound in this type declaration.
|}]