diff options
author | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2005-09-15 03:09:26 +0000 |
---|---|---|
committer | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2005-09-15 03:09:26 +0000 |
commit | c54747bf82facad52e4df9476b9c6a75c21f3a52 (patch) | |
tree | 93041abe8719fd69ad042e3f7d82992cbc78c6e2 | |
parent | a5f0fd6a27c9d87669084ddc9b58cc0893c0dda6 (diff) |
warn about useless with in record
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7051 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-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 *) ;; |