summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Weis <Pierre.Weis@inria.fr>2003-05-02 08:46:06 +0000
committerPierre Weis <Pierre.Weis@inria.fr>2003-05-02 08:46:06 +0000
commit0db5921ea801e28554b8554ffaa4c7155dad3365 (patch)
treec64b1b7bac47fbb22ab9acee4fd820d62fc6d752
parente77055aad9ff89c61aae94d0e5d6f1c492b830fd (diff)
Introduction du warning Fragile_pat pour signaler les filtrages
exhaustifs mais fragiles, car sensibles à la modification des types qu'ils filtrent: une modification d'un des types resterait insoupçonnée au sens où aucun Warning de filtrage ne serait émis par le compilateur. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5525 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--utils/warnings.ml11
-rw-r--r--utils/warnings.mli1
2 files changed, 11 insertions, 1 deletions
diff --git a/utils/warnings.ml b/utils/warnings.ml
index 7b37a8f13..8848a4efd 100644
--- a/utils/warnings.ml
+++ b/utils/warnings.ml
@@ -17,6 +17,7 @@
type t = (* A is all *)
| Comment of string (* C *)
| Deprecated (* D *)
+ | Fragile_pat of string (* E *)
| Partial_application (* F *)
| Labels_omitted (* L *)
| Method_override of string list (* M *)
@@ -31,6 +32,7 @@ type t = (* A is all *)
let letter = function (* 'a' is all *)
| Comment _ -> 'c'
| Deprecated -> 'd'
+ | Fragile_pat _ -> 'e'
| Partial_application -> 'f'
| Labels_omitted -> 'l'
| Method_override _ -> 'm'
@@ -42,7 +44,7 @@ let letter = function (* 'a' is all *)
;;
let check c =
- try ignore (String.index "acdflmpsuvxACDFLMPSUVX" c)
+ try ignore (String.index "acdeflmpsuvxACDEFLMPSUVX" c)
with _ -> raise (Arg.Bad (Printf.sprintf "unknown warning option %c" c))
;;
@@ -88,6 +90,13 @@ let message = function
Here is an example of a value that is not matched:\n" ^ s
| Unused_match -> "this match case is unused."
| Unused_pat -> "this pattern is unused."
+ | Fragile_pat "" ->
+ "this pattern is fragile: it would not cause a warning \n\
+ in case of modification of the data types it matches."
+ | Fragile_pat s ->
+ "this pattern is fragile: it would not cause a warning \n\
+ in case of modification of the data types it matches.\n\
+ Here is an example of a more robust pattern:\n" ^ s
| Labels_omitted ->
"labels were omitted in the application of this function."
| Method_override slist ->
diff --git a/utils/warnings.mli b/utils/warnings.mli
index 104d62156..d23a3188b 100644
--- a/utils/warnings.mli
+++ b/utils/warnings.mli
@@ -17,6 +17,7 @@ open Format
type t = (* A is all *)
| Comment of string (* C *)
| Deprecated (* D *)
+ | Fragile_pat of string (* E *)
| Partial_application (* F *)
| Labels_omitted (* L *)
| Method_override of string list (* M *)