Ocaml record type usage

I just found out that the following code to access a record field is valid,

module A = struct type a = {field1:string;field2:int} end;;
let a = {A.field1 = "hello"; field2 = 100};;

a.field1 = a.A.field1;;  (* this is valid, i.e. a.A.field1 *)

Is this documented somewhere in the manual?

It is documented in the technical description of the language: https://caml.inria.fr/pub/docs/manual-ocaml/expr.html#sec150 . But it seems that indeed qualified record fields are not described in the tutorial part of the manual.

You can also write

let a = A.{field1 = "hello"; field2 = 100};;

which is often more convenient as you don’t have to repeat the module name.

Though this has a bit different semantics. In this case it makes no difference since the code uses only literals, but in this code:

let open A in
{field1 = "hello"; field2 = value}

it would try to use A.value if there was one defined. Which is an easy way to get tripped up.