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
|
let () = () |> (let type u = A in f ~y:0)
let _ =
let type t = A in
A
let _ =
let type t = .. in
let type t += A in
A
type u = ..
let _ =
let type u += A in
A
let _ =
let class c = object method f = 12 end in
new c
let _ =
let external f : 'a -> 'a = "%identity" in
f
let _ =
let type t = A of int | B in
let _ = [A 42; B] in
let type t = .. in
let type t += A of string in
let _ = A "hello" in
let class c = object method f = 42 end in
let class type ct = object method f : int end in
let class d : ct = object (self) inherit c initializer print_int (self # f) end in
let external f : 'a -> 'a = "%identity" in
let [@@@warning "-unused-var"] in
let v = (42, 12) in
assert (f v == v);
"OK"
(* PR#14554, a regression reported by Antonio Monteiro.
(The regressions or fixes are after 5.4, which is the last release
without the generic [Pexp_struct_item] typing rules of #13839).
In each example below, we expect the inferred type
{[
val dog : < bark : 'this -> unit > t as 'this
]}
where the ['this] variable has been generalized,
it is not a weak variable like ['_this].
*)
type 'a t
(* This was correct in OCaml 5.4,
and was temporarily broken by #13839. *)
let dog : 'this =
let module Dog = struct
external make
: bark:('self -> unit)
-> < bark : ('self -> unit) > t = "%identity"
end
in
Dog.make ~bark:(fun (o : 'this) -> ())
(* This variant from Samuel Vivien would also
suffer from the same regression. *)
let dog : 'this =
let
external make
: bark:('self -> unit)
-> < bark : ('self -> unit) > t = "%identity"
in
make ~bark:(fun (o : 'this) -> ())
(* This variant from Gabriel Scherer was already wrong in OCaml 5.4,
and has been fixed at the same time as the other two. *)
let dog : 'this =
let open struct
external make
: bark:('self -> unit)
-> < bark : ('self -> unit) > t = "%identity"
end in
make ~bark:(fun (o : 'this) -> ())
(* </end of #14554> *)
let _ =
let type t = Foooooooooooooooooooooooooooooooooooooooooooooooooo | Baaaaaaaaaaaaaaaaaaaaaaaar in
let module rec Foooooooooooooooooooooooooooooooooooooooooooooooooooooooo = struct end in
()
|