File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -88,6 +88,7 @@ type t =
8888 | Bs_toplevel_expression_unit of
8989 (string * top_level_unit_help ) option (* 109 *)
9090 | Bs_todo of string option (* 110 *)
91+ | Bs_record_rest_empty (* 111 *)
9192
9293(* If you remove a warning, leave a hole in the numbering. NEVER change
9394 the numbers of existing warnings.
@@ -154,8 +155,9 @@ let number = function
154155 | Bs_uninterpreted_delimiters _ -> 108
155156 | Bs_toplevel_expression_unit _ -> 109
156157 | Bs_todo _ -> 110
158+ | Bs_record_rest_empty -> 111
157159
158- let last_warning_number = 110
160+ let last_warning_number = 111
159161
160162let letter_all =
161163 let rec loop i = if i = 0 then [] else i :: loop (i - 1 ) in
@@ -532,6 +534,9 @@ let message = function
532534 `%s->ignore`"
533535 help_text help_text
534536 | _ -> " " )
537+ | Bs_record_rest_empty ->
538+ " All fields of the rest type are already present in the explicit pattern. \
539+ The rest record will always be empty."
535540 | Bs_todo maybe_text ->
536541 (match maybe_text with
537542 | None -> " Todo found."
Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ type t =
8181 | Bs_toplevel_expression_unit of
8282 (string * top_level_unit_help ) option (* 109 *)
8383 | Bs_todo of string option (* 110 *)
84+ | Bs_record_rest_empty (* 111 *)
8485
8586val parse_options : bool -> string -> unit
8687
Original file line number Diff line number Diff line change @@ -1608,6 +1608,15 @@ and type_pat_aux ~constrs ~labels ~no_existentials ~mode ~explode ~env sp
16081608 (fun (l : Types.label_declaration ) -> Ident. name l.ld_id)
16091609 rest_labels
16101610 in
1611+ (* Warn if all rest fields are already explicit — the rest record will be empty *)
1612+ if
1613+ rest_field_names <> []
1614+ && List. for_all
1615+ (fun f -> List. mem f explicit_fields)
1616+ rest_field_names
1617+ then
1618+ Location. prerr_warning rest_pat.ppat_loc
1619+ Warnings. Bs_record_rest_empty ;
16111620 (* Validate: fields in both explicit and rest must be optional in the explicit pattern *)
16121621 let not_optional =
16131622 List. filter
You can’t perform that action at this time.
0 commit comments