let f0 () =
let r = ref [] in
!r
let f1 () : 'a list =
let r = ref ([] : 'a list) in
!r
let f2 () =
let r : ('a ref) = ref [] in
!r
let f3 () =
let r : (int list) ref = ref [] in
!r
let f4 () =
let r = ref ([] : int list) in
!r
let g1 () : 'a list =
let r = ref [] in
r := [5];
!r
let g2 () =
let r : ('a list) ref = ref [] in
r := [4];
!r
let m0 () =
let r = ref [] in
r
let h0 () =
let g =
let f () = ref [] in
f in
g
(* not allowed because produces a ['_a list ref] at top level;
i.e. rejected when using OCaml "-strict_value_restriction" flag
let h1 =
let f () : 'a list ref = ref [] in
f
*)
let h2 () =
let f () : 'a list ref = ref [] in
f
let h3 () =
let f () = ref [] in
f()
let k1 () =
[]
let k2 () =
ref []
(* CF does not typecheck because the type cannot be resolved
let r1 () =
let _x = ref [] in
()
*)
(* CF does not typecheck because the type cannot be resolved
let r2 () =
let _x = ref [] in
let y = [] in
y
*)
type 'a sitems = {
mutable nb : int;
mutable items : 'a list; }
let sitems_build n =
{ nb = n; items = [] }
let sitems_incr_nb_let r =
let x = r.nb in
r.nb <- x + 1
let sitems_length_items_let r =
let x = r.items in
List.length x