summaryrefslogtreecommitdiff
path: root/testsuite/tests/typing-objects/Tests.ml.principal.reference
blob: 52f2a09282e1e1243d68086953632dfa70bbdabf (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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312

#   - : < x : int > ->
    < x : int > -> < x : int > -> < x : int > * < x : int > * < x : int >
= <fun>
#               class ['a] c : unit -> object constraint 'a = int method f : int c end
and ['a] d : unit -> object constraint 'a = int method f : int c end
#                 Characters 238-275:
  ........d () = object
    inherit ['a] c ()
  end..
Error: Some type variables are unbound in this type:
         class d : unit -> object method f : 'a -> unit end
       The method f has type 'a -> unit where 'a is unbound
#             class virtual c : unit -> object  end
and ['a] d :
  unit -> object constraint 'a = < x : int; .. > method f : 'a -> int end
#                 class ['a] c : unit -> object constraint 'a = int end
and ['a] d : unit -> object constraint 'a = int #c end
# *             class ['a] c :
  'a -> object ('a) constraint 'a = < f : 'a; .. > method f : 'a end
# - : ('a c as 'a) -> 'a = <fun>
# *           Characters 134-176:
  ......x () = object
    method virtual f : int
  end..
Error: This class should be virtual. The following methods are undefined : f
#               Characters 139-147:
  class virtual c ((x : 'a): < f : int >) = object (_ : 'a) end
                                                   ^^^^^^^^
Error: This pattern cannot match self: it only matches values of type
       < f : int >
#           Characters 38-110:
  ......['a] c () = object
    constraint 'a = int
    method f x = (x : bool c)
  end..
Error: The abbreviation c is used with parameters bool c
       wich are incompatible with constraints int c
#             class ['a, 'b] c :
  unit ->
  object
    constraint 'a = int -> 'c
    constraint 'b = 'a * < x : 'b > * 'c * 'd
    method f : 'a -> 'b -> unit
  end
#     class ['a, 'b] d :
  unit ->
  object
    constraint 'a = int -> 'c
    constraint 'b = 'a * < x : 'b > * 'c * 'd
    method f : 'a -> 'b -> unit
  end
#     val x : '_a list ref = {contents = []}
#     Characters 6-50:
  ......['a] c () = object
    method f = (x : 'a)
  end..
Error: The type of this class,
       class ['a] c :
         unit -> object constraint 'a = '_b list ref method f : 'a end,
       contains type variables that cannot be generalized
#       Characters 24-52:
  type 'a c = <f : 'a c; g : 'a d>
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: In the definition of d, type int c should be 'a c
#   type 'a c = < f : 'a c; g : 'a d >
and 'a d = < f : 'a c >
#   type 'a c = < f : 'a c >
and 'a d = < f : int c >
#   type 'a u = < x : 'a >
and 'a t = 'a t u
#   Characters 18-32:
  and 'a t = 'a t u;;
     ^^^^^^^^^^^^^^
Error: The type abbreviation t is cyclic
# type 'a u = 'a
# Characters 5-18:
  type t = t u * t u;;
       ^^^^^^^^^^^^^
Error: The type abbreviation t is cyclic
#   type t = < x : 'a > as 'a
# type 'a u = 'a
# - : t -> t u -> bool = <fun>
# - : t -> t u -> bool = <fun>
#                         module M :
  sig
    class ['a, 'b] c :
      int ->
      'b ->
      object
        constraint 'a = int -> bool
        val x : float list
        val y : 'b
        method f : 'a -> unit
        method g : 'b
      end
  end
#                   module M' :
  sig
    class virtual ['a, 'b] c :
      int ->
      'b ->
      object
        constraint 'a = int -> bool
        val x : float list
        val y : 'b
        method f : 'a -> unit
        method g : 'b
      end
  end
# class ['a, 'b] d :
  unit ->
  'b ->
  object
    constraint 'a = int -> bool
    val x : float list
    val y : 'b
    method f : 'a -> unit
    method g : 'b
  end
# class ['a, 'b] e :
  unit ->
  'b ->
  object
    constraint 'a = int -> bool
    val x : float list
    val y : 'b
    method f : 'a -> unit
    method g : 'b
  end
# - : string = "a"
# - : int = 10
# - : float = 7.1
# # - : bool = true
#     module M : sig class ['a] c : unit -> object method f : 'a -> unit end end
#   module M' : sig class ['a] c : unit -> object method f : 'a -> unit end end
# - : ('a #M.c as 'b) -> 'b = <fun>
# - : ('a #M'.c as 'b) -> 'b = <fun>
# class ['a] c : 'a #c -> object  end
# class ['a] c : 'a #c -> object  end
#     class c : unit -> object method f : int end
and d : unit -> object method f : int end
# class e : unit -> object method f : int end
# - : int = 2
# Characters 30-34:
  class c () = object val x = - true val y = -. () end;;
                                ^^^^
Error: This expression has type bool but an expression was expected of type
         int
#   class c : unit -> object method f : int method g : int method h : int end
# class d : unit -> object method h : int method i : int method j : int end
#               class e :
  unit ->
  object
    method f : int
    method g : int
    method h : int
    method i : int
    method j : int
  end
# val e : e = <obj>
# - : int * int * int * int * int = (1, 3, 2, 2, 3)
#   class c : 'a -> object val a : 'a val x : int val y : int val z : int end
# class d : 'a -> object val b : 'a val t : int val u : int val z : int end
#                             Characters 42-45:
    inherit c 5
            ^^^
Warning 13: the following instance variables are overridden by the class c :
  x
The behaviour changed in ocaml 3.10 (previous behaviour was hiding.)
Characters 52-53:
    val y = 3
        ^
Warning 13: the instance variable y is overridden.
The behaviour changed in ocaml 3.10 (previous behaviour was hiding.)
Characters 80-83:
    inherit d 7
            ^^^
Warning 13: the following instance variables are overridden by the class d :
  t z
The behaviour changed in ocaml 3.10 (previous behaviour was hiding.)
Characters 90-91:
    val u = 3
        ^
Warning 13: the instance variable u is overridden.
The behaviour changed in ocaml 3.10 (previous behaviour was hiding.)
class e :
  unit ->
  object
    val a : int
    val b : int
    val t : int
    val u : int
    val x : int
    val y : int
    val z : int
    method a : int
    method b : int
    method t : int
    method u : int
    method x : int
    method y : int
    method z : int
  end
# val e : e = <obj>
# - : int * int * int * int * int * int * int = (1, 3, 2, 2, 3, 5, 7)
#             class c :
  int ->
  int -> object val x : int val y : int method x : int method y : int end
# class d :
  int ->
  int -> object val x : int val y : int method x : int method y : int end
# - : int * int = (1, 2)
# - : int * int = (1, 2)
#     class ['a] c : 'a -> object  end
# - : 'a -> 'a c = <fun>
#     * * * * * * * * * * * * * * * * * * * * *                             module M : sig class c : unit -> object method xc : int end end
#         class d : unit -> object val x : int method xc : int method xd : int end
# - : int * int = (1, 2)
#         Characters 7-156:
  ......virtual ['a] matrix (sz, init : int * 'a) = object
    val m = Array.create_matrix sz sz init
    method add (mtx : 'a matrix) = (mtx#m.(0).(0) : 'a)
  end..
Error: The abbreviation 'a matrix expands to type < add : 'a matrix -> 'a >
       but is used with type < m : 'a array array; .. >
#   class c : unit -> object method m : c end
# - : c = <obj>
# module M : sig class c : unit -> object method m : c end end
# - : M.c = <obj>
#   type uu = A of int | B of (< leq : 'a > as 'a)
#   class virtual c : unit -> object ('a) method virtual m : 'a end
#         module S : sig val f : (#c as 'a) -> 'a end
#         Characters 12-43:
  ............struct
    let f (x : #c) = x
  end......
Error: Signature mismatch:
       Modules do not match:
         sig val f : (#c as 'a) -> 'a end
       is not included in
         sig val f : #c -> #c end
       Values do not match:
         val f : (#c as 'a) -> 'a
       is not included in
         val f : #c -> #c
#   Characters 32-55:
  module M = struct type t = int class t () = object end end;;
                                 ^^^^^^^^^^^^^^^^^^^^^^^
Error: Multiple definition of the type name t.
       Names must be unique in a given structure or signature.
#   - : < m : (< m : 'a > as 'b) -> 'b as 'a; .. > -> 'b = <fun>
#   Characters 10-39:
  fun x -> (x : int -> bool :> 'a -> 'a);;
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Type int -> bool is not a subtype of int -> int 
       Type bool is not a subtype of int 
# Characters 9-40:
  fun x -> (x : int -> bool :> int -> int);;
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Type int -> bool is not a subtype of int -> int 
       Type bool is not a subtype of int 
# - : <  > -> <  > = <fun>
# - : < .. > -> <  > = <fun>
#   val x : '_a list ref = {contents = []}
#   module F : functor (X : sig  end) -> sig type t = int end
# - : < m : int > list ref = {contents = []}
#   type 'a t
# Characters 9-19:
  fun (x : 'a t as 'a) -> ();;
           ^^^^^^^^^^
Error: This alias is bound to type 'a t but is used as an instance of type 'a
       The type variable 'a occurs inside 'a t
# Characters 19-20:
  fun (x : 'a t) -> (x : 'a); ();;
                     ^
Error: This expression has type 'a t but an expression was expected of type
         'a
       The type variable 'a occurs inside 'a t
# type 'a t = < x : 'a >
# - : ('a t as 'a) -> unit = <fun>
# Characters 18-26:
  fun (x : 'a t) -> (x : 'a); ();;
                    ^^^^^^^^
Warning 10: this expression should have type unit.
- : ('a t as 'a) t -> unit = <fun>
#         class ['a] c :
  unit ->
  object constraint 'a = (< .. > as 'b) -> unit method m : 'b -> unit end
#       class ['a] c :
  unit ->
  object constraint 'a = unit -> (< .. > as 'b) method m : 'a -> 'b end
#         class c : unit -> object method private m : int method n : int end
#         class d :
  unit -> object method private m : int method n : int method o : int end
#   - : int * int = (1, 1)
#   class c : unit -> object method m : int end
#       - : int = 16
# - : int = 17
# - : int = 18
#         - : int * int * int = (19, 20, 21)
#           - : int * int * int * int * int = (22, 23, 24, 33, 33)
#           - : int * int * int * int * int = (25, 26, 27, 33, 33)
#         Characters 42-69:
  class a = let _ = new b in object end
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This kind of recursive class expression is not allowed
#   Characters 11-38:
  class a = let _ = new a in object end;;
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This kind of recursive class expression is not allowed
#