diff options
-rw-r--r-- | typing/typecore.ml | 4 | ||||
-rw-r--r-- | utils/warnings.ml | 5 | ||||
-rw-r--r-- | utils/warnings.mli | 1 |
3 files changed, 9 insertions, 1 deletions
diff --git a/typing/typecore.ml b/typing/typecore.ml index f81b58f53..44a0738e2 100644 --- a/typing/typecore.ml +++ b/typing/typecore.ml @@ -1049,7 +1049,9 @@ let rec type_exp env sexp = in let missing = missing_labels 0 label_names in raise(Error(sexp.pexp_loc, Label_missing missing)) - end; + end + else if opt_sexp <> None && List.length lid_sexp_list = !num_fields then + Location.prerr_warning sexp.pexp_loc Warnings.Useless_record_with; re { exp_desc = Texp_record(lbl_exp_list, opt_exp); exp_loc = sexp.pexp_loc; diff --git a/utils/warnings.ml b/utils/warnings.ml index f45d68b97..3adda4666 100644 --- a/utils/warnings.ml +++ b/utils/warnings.ml @@ -37,6 +37,7 @@ type t = (* A is all *) | Nonreturning_statement | Camlp4 of string | All_clauses_guarded + | Useless_record_with | Unused_var of string (* Y *) | Unused_var_strict of string (* Z *) ;; @@ -63,6 +64,7 @@ let letter = function (* 'a' is all *) | Unused_argument | Nonreturning_statement | Camlp4 _ + | Useless_record_with | All_clauses_guarded -> 'x' | Unused_var _ -> 'y' | Unused_var_strict _ -> 'z' @@ -149,6 +151,9 @@ let message = function | Camlp4 s -> s | All_clauses_guarded -> "bad style, all clauses in this pattern-matching are guarded." + | Useless_record_with -> + "this record is defined by a `with' expression,\n\ + but no fields are borrowed from the original." ;; let nerrors = ref 0;; diff --git a/utils/warnings.mli b/utils/warnings.mli index a623bb2c7..5f22c91be 100644 --- a/utils/warnings.mli +++ b/utils/warnings.mli @@ -37,6 +37,7 @@ type t = (* A is all *) | Nonreturning_statement | Camlp4 of string | All_clauses_guarded + | Useless_record_with | Unused_var of string (* Y *) | Unused_var_strict of string (* Z *) ;; |