Source

compiler-libs-hack / ocaml / testsuite / tests / typing-misc / records.ml.principal.reference

Full commit

#   type t = { x : int; y : int; }
# Characters 5-6:
  {x=3;z=2};;
       ^
Error: Unbound record field z
# Characters 9-10:
  fun {x=3;z=2} -> ();;
           ^
Error: Unbound record field z
#     Characters 26-34:
  {x=3; contents=2};;
        ^^^^^^^^
Error: The record field contents belongs to the type 'a ref
       but is mixed here with fields of type t
#     type u = private { mutable u : int; }
# Characters 0-5:
  {u=3};;
  ^^^^^
Error: Cannot create values of the private type u
# Characters 11-12:
  fun x -> x.u <- 3;;
             ^
Error: Cannot assign field u of the private type u
#         module M : sig type t = { x : int; y : int; } end
#   val f : M.t -> int = <fun>
# val r : M.t = {M.x = 1; y = 2}
# val z : int = 3
#     type foo = { mutable y : int; }
# Characters 17-18:
  let f (r: int) = r.y <- 3;;
                   ^
Error: This expression has type int but an expression was expected of type
         foo
#     type foo = { y : int; z : int; }
# type bar = { x : int; }
#     Characters 20-21:
  let f (r: bar) = ({ r with z = 3 } : foo)
                      ^
Error: This expression has type bar but an expression was expected of type
         foo
# Characters 16-21:
  let r : foo = { ZZZ.x = 2 };;
                  ^^^^^
Error: Unbound module ZZZ
#   Characters 2-7:
  (ZZZ.X : int option);;
   ^^^^^
Error: Unbound module ZZZ
#     Characters 41-50:
  let f (x : Complex.t) = x.Complex.z;;
                            ^^^^^^^^^
Error: Unbound record field Complex.z
#