@@ -41404,7 +41404,7 @@ and record_representation =
4140441404 | Record_float_unused (* Was: all fields are floats. Now: unused *)
4140541405 | Record_unboxed of bool (* Unboxed single-field record, inlined or not *)
4140641406 | Record_inlined of (* Inlined record *)
41407- { tag : int ; name : string; num_nonconsts : int}
41407+ { tag : int ; name : string; num_nonconsts : int; optional_labels : string list }
4140841408 | Record_extension (* Inlined record under extension *)
4140941409 | Record_optional_labels of string list (* List of optional labels *)
4141041410
@@ -41749,7 +41749,7 @@ and record_representation =
4174941749 | Record_float_unused (* Was: all fields are floats. Now: unused *)
4175041750 | Record_unboxed of bool (* Unboxed single-field record, inlined or not *)
4175141751 | Record_inlined of (* Inlined record *)
41752- { tag : int ; name : string; num_nonconsts : int}
41752+ { tag : int ; name : string; num_nonconsts : int; optional_labels : string list }
4175341753 | Record_extension (* Inlined record under extension *)
4175441754 | Record_optional_labels of string list (* List of optional labels *)
4175541755
@@ -41943,10 +41943,10 @@ let same_record_representation x y =
4194341943 match y with
4194441944 | Record_optional_labels lbls2 -> lbls = lbls2
4194541945 | _ -> false)
41946- | Record_inlined {tag; name; num_nonconsts} -> (
41946+ | Record_inlined {tag; name; num_nonconsts; optional_labels } -> (
4194741947 match y with
4194841948 | Record_inlined y ->
41949- tag = y.tag && name = y.name && num_nonconsts = y.num_nonconsts
41949+ tag = y.tag && name = y.name && num_nonconsts = y.num_nonconsts && optional_labels = y.optional_labels
4195041950 | _ -> false)
4195141951 | Record_extension -> y = Record_extension
4195241952 | Record_unboxed x -> ( match y with Record_unboxed y -> x = y | _ -> false)
@@ -43435,6 +43435,7 @@ let constructor_descrs ty_path decl cstrs =
4343543435 if cd_args = Cstr_tuple [] then incr num_consts else incr num_nonconsts;
4343643436 if cd_res = None then incr num_normal)
4343743437 cstrs;
43438+ let has_optional attrs = Ext_list.exists attrs (fun ({txt },_) -> txt = "ns.optional") in
4343843439 let rec describe_constructors idx_const idx_nonconst = function
4343943440 [] -> []
4344043441 | {cd_id; cd_args; cd_res; cd_loc; cd_attributes} :: rem ->
@@ -43453,11 +43454,17 @@ let constructor_descrs ty_path decl cstrs =
4345343454 | _ -> (Cstr_block idx_nonconst,
4345443455 describe_constructors idx_const (idx_nonconst+1) rem) in
4345543456 let cstr_name = Ident.name cd_id in
43457+ let optional_labels = match cd_args with
43458+ | Cstr_tuple _ -> []
43459+ | Cstr_record lbls ->
43460+ Ext_list.filter_map lbls (fun ({ld_id;ld_attributes; _}) ->
43461+ if has_optional ld_attributes then Some ld_id.name else None)
43462+ in
4345643463 let existentials, cstr_args, cstr_inlined =
4345743464 let representation =
4345843465 if decl.type_unboxed.unboxed
4345943466 then Record_unboxed true
43460- else Record_inlined {tag = idx_nonconst; name = cstr_name; num_nonconsts = !num_nonconsts}
43467+ else Record_inlined {tag = idx_nonconst; name = cstr_name; num_nonconsts = !num_nonconsts; optional_labels }
4346143468 in
4346243469 constructor_args decl.type_private cd_args cd_res
4346343470 (Path.Pdot (ty_path, cstr_name, Path.nopos)) representation
0 commit comments