@@ -215266,7 +215266,7 @@ type error =
215266
215266
| Apply_non_function of type_expr
215267
215267
| Apply_wrong_label of arg_label * type_expr
215268
215268
| Label_multiply_defined of string
215269
- | Label_missing of string list
215269
+ | Labels_missing of string list
215270
215270
| Label_not_mutable of Longident.t
215271
215271
| Wrong_name of string * type_expr * string * Path.t * string * string list
215272
215272
| Name_type_mismatch of
@@ -215371,7 +215371,7 @@ type error =
215371
215371
| Apply_non_function of type_expr
215372
215372
| Apply_wrong_label of arg_label * type_expr
215373
215373
| Label_multiply_defined of string
215374
- | Label_missing of string list
215374
+ | Labels_missing of string list
215375
215375
| Label_not_mutable of Longident.t
215376
215376
| Wrong_name of string * type_expr * string * Path.t * string * string list
215377
215377
| Name_type_mismatch of
@@ -217503,7 +217503,8 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected =
217503
217503
unify_exp_types loc env ty_record (instance env ty_expected);
217504
217504
check_duplicates loc env lbl_exp_list;
217505
217505
let (_, { lbl_all = label_descriptions; lbl_repres = representation}, _) = List.hd lbl_exp_list in
217506
- let label_definitions =
217506
+ let labels_missing = ref [] in
217507
+ let label_definitions =
217507
217508
let matching_label lbl =
217508
217509
List.find
217509
217510
(fun (_, lbl',_) -> lbl'.lbl_pos = lbl.lbl_pos)
@@ -217515,13 +217516,12 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected =
217515
217516
| (lid, _lbl, lbl_exp) ->
217516
217517
Overridden (lid, lbl_exp)
217517
217518
| exception Not_found ->
217518
- if label_is_optional lbl then
217519
- Overridden ({loc ; txt = Lident lbl.lbl_name},
217520
- option_none lbl.lbl_arg loc)
217521
- else
217522
- raise(Error(loc, env, Label_missing [lbl.lbl_name])))
217519
+ if not (label_is_optional lbl) then labels_missing := lbl.lbl_name :: !labels_missing;
217520
+ Overridden ({loc ; txt = Lident lbl.lbl_name}, option_none lbl.lbl_arg loc))
217523
217521
label_descriptions
217524
217522
in
217523
+ if !labels_missing <> [] then
217524
+ raise(Error(loc, env, Labels_missing (List.rev !labels_missing)));
217525
217525
let fields =
217526
217526
Array.map2 (fun descr def -> descr, def)
217527
217527
label_descriptions label_definitions
@@ -218979,10 +218979,10 @@ let report_error env ppf = function
218979
218979
type_expr ty print_label l
218980
218980
| Label_multiply_defined s ->
218981
218981
fprintf ppf "The record field label %s is defined several times" s
218982
- | Label_missing labels ->
218982
+ | Labels_missing labels ->
218983
218983
let print_labels ppf =
218984
218984
List.iter (fun lbl -> fprintf ppf "@ %s" ( lbl)) in
218985
- fprintf ppf "@[<hov>Some record fields are undefined :%a@]"
218985
+ fprintf ppf "@[<hov>Some required record fields are missing :%a@]"
218986
218986
print_labels labels
218987
218987
| Label_not_mutable lid ->
218988
218988
fprintf ppf "The record field %a is not mutable" longident lid
0 commit comments