blob: ddc5d165236afcb6e115c064f3ff4ba2e51b0d0d (
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
(* TEST
expect;
*)
class type foo_t =
object
method foo: string
end
module M: sig
class type ct = object val m: string end
end = struct
class type ct = object end
end
[%%expect{|
class type foo_t = object method foo : string end
Lines 8-10, characters 6-3:
8 | ......struct
9 | class type ct = object end
10 | end
Error: Signature mismatch:
Modules do not match:
sig class type ct = object end end
is not included in
sig class type ct = object val m : string end end
Class type declarations do not match:
class type ct = object end
does not match
class type ct = object val m : string end
The first class type has no instance variable m
|}]
module M: sig
class c : object
method a: string
end
end = struct
class virtual c = object
method virtual a: string
end
end
;;
[%%expect{|
Lines 5-9, characters 6-3:
5 | ......struct
6 | class virtual c = object
7 | method virtual a: string
8 | end
9 | end
Error: Signature mismatch:
Modules do not match:
sig class virtual c : object method virtual a : string end end
is not included in
sig class c : object method a : string end end
Class declarations do not match:
class virtual c : object method virtual a : string end
does not match
class c : object method a : string end
A class cannot be changed from virtual to concrete
|}]
class type ['a] ct = object val x: 'a end
module M: sig
class type ['a] c = object end
end = struct
class type c = object end
end
;;
[%%expect{|
class type ['a] ct = object val x : 'a end
Lines 5-7, characters 6-3:
5 | ......struct
6 | class type c = object end
7 | end
Error: Signature mismatch:
Modules do not match:
sig class type c = object end end
is not included in
sig class type ['a] c = object end end
Class type declarations do not match:
class type c = object end
does not match
class type ['a] c = object end
The classes do not have the same number of type parameters
|}]
module M: sig
class ['a] c: object constraint 'a = int end
end = struct
class ['a] c = object end
end
;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | class ['a] c = object end
5 | end
Error: Signature mismatch:
Modules do not match:
sig class ['a] c : object end end
is not included in
sig class ['a] c : object constraint 'a = int end end
Class declarations do not match:
class ['a] c : object end
does not match
class ['a] c : object constraint 'a = int end
A type parameter has type 'a but is expected to have type int
|}]
module M: sig
class c : int -> object end
end = struct
class c (x : float) = object end
end
;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | class c (x : float) = object end
5 | end
Error: Signature mismatch:
Modules do not match:
sig class c : float -> object end end
is not included in
sig class c : int -> object end end
Class declarations do not match:
class c : float -> object end
does not match
class c : int -> object end
A parameter has type float but is expected to have type int
|}]
class virtual foo: foo_t =
object
method foo = "foo"
method private virtual cast: int
end
;;
[%%expect{|
Lines 2-5, characters 4-7:
2 | ....object
3 | method foo = "foo"
4 | method private virtual cast: int
5 | end
Error: The class type
object method private virtual cast : int method foo : string end
is not matched by the class type foo_t
The virtual method cast cannot be hidden
|}]
class type foo_t2 =
object
method private foo: string
end
class foo: foo_t2 =
object
method foo = "foo"
end
;;
[%%expect{|
class type foo_t2 = object method private foo : string end
Lines 7-9, characters 4-7:
7 | ....object
8 | method foo = "foo"
9 | end
Error: The class type object method foo : string end
is not matched by the class type foo_t2
The public method foo cannot become private
|}]
class virtual foo: foo_t =
object
method virtual foo: string
end
;;
[%%expect{|
Lines 2-4, characters 4-7:
2 | ....object
3 | method virtual foo: string
4 | end
Error: The class type object method virtual foo : string end
is not matched by the class type foo_t
The virtual method foo cannot become concrete
|}]
class type foo_t3 =
object
val mutable x : int
end
class foo: foo_t3 =
object
val x = 1
end
;;
[%%expect{|
class type foo_t3 = object val mutable x : int end
Lines 7-9, characters 4-7:
7 | ....object
8 | val x = 1
9 | end
Error: The class type object val x : int end is not matched by the class type
foo_t3
The non-mutable instance variable x cannot become mutable
|}]
class type foo_t4 =
object
val x : int
end
class virtual foo: foo_t4 =
object
val virtual x : int
end
;;
[%%expect{|
class type foo_t4 = object val x : int end
Lines 7-9, characters 4-7:
7 | ....object
8 | val virtual x : int
9 | end
Error: The class type object val virtual x : int end
is not matched by the class type foo_t4
The virtual instance variable x cannot become concrete
|}]
module M: sig
class type c = object method m: string end
end = struct
class type c = object method private m: string end
end
;;
[%%expect{|
Lines 3-5, characters 6-3:
3 | ......struct
4 | class type c = object method private m: string end
5 | end
Error: Signature mismatch:
Modules do not match:
sig class type c = object method private m : string end end
is not included in
sig class type c = object method m : string end end
Class type declarations do not match:
class type c = object method private m : string end
does not match
class type c = object method m : string end
The private method m cannot become public
|}]
|