|
23 | 23 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) |
24 | 24 |
|
25 | 25 |
|
26 | | -type warning_error = |
27 | | - | Warn_error_false |
| 26 | +type warning_error = |
| 27 | + | Warn_error_false |
28 | 28 | (* default [false] to make our changes non-intrusive *) |
29 | 29 | | Warn_error_true |
30 | | - | Warn_error_number of string |
| 30 | + | Warn_error_number of string |
31 | 31 |
|
32 | 32 | type t = { |
33 | 33 | number : string option; |
34 | 34 | error : warning_error |
35 | 35 | } |
36 | 36 |
|
| 37 | +(** |
| 38 | + See the meanings of the warning codes here: https://caml.inria.fr/pub/docs/manual-ocaml/comp.html#sec281 |
| 39 | +
|
| 40 | + - 30 Two labels or constructors of the same name are defined in two mutually recursive types. |
| 41 | + - 40 Constructor or label name used out of scope. |
| 42 | +
|
| 43 | + - 6 Label omitted in function application. |
| 44 | + - 7 Method overridden. |
| 45 | + - 9 Missing fields in a record pattern. (*Not always desired, in some cases need [@@@warning "+9"] *) |
| 46 | + - 27 Innocuous unused variable: unused variable that is not bound with let nor as, and doesn’t start with an underscore (_) character. |
| 47 | + - 29 Unescaped end-of-line in a string constant (non-portable code). |
| 48 | + - 32 .. 39 Unused blabla |
| 49 | + - 44 Open statement shadows an already defined identifier. |
| 50 | + - 45 Open statement shadows an already defined label or constructor. |
| 51 | + - 48 Implicit elimination of optional arguments. https://caml.inria.fr/mantis/view.php?id=6352 |
| 52 | + - 101 (bsb-specific) unsafe polymorphic comparison. |
| 53 | +*) |
37 | 54 | let default_warning_flag = "-w -30-40+6+7+27+32..39+44+45+101" |
38 | 55 |
|
39 | | -let get_warning_flag x = |
40 | | - default_warning_flag ^ |
41 | | - (match x with |
| 56 | +let get_warning_flag x = |
| 57 | + default_warning_flag ^ |
| 58 | + (match x with |
42 | 59 | | Some {number =None} |
43 | 60 | | None -> Ext_string.empty |
44 | 61 | | Some {number = Some x} -> Ext_string.trim x ) |
45 | 62 |
|
46 | 63 |
|
47 | 64 | let warn_error = " -warn-error A" |
48 | 65 |
|
49 | | -let warning_to_string not_dev |
50 | | - warning : string = |
51 | | - default_warning_flag ^ |
52 | | - (match warning.number with |
53 | | - | None -> |
| 66 | +let warning_to_string not_dev |
| 67 | + warning : string = |
| 68 | + default_warning_flag ^ |
| 69 | + (match warning.number with |
| 70 | + | None -> |
54 | 71 | Ext_string.empty |
55 | | - | Some x -> |
| 72 | + | Some x -> |
56 | 73 | Ext_string.trim x) ^ |
57 | | - if not_dev then Ext_string.empty |
| 74 | + if not_dev then Ext_string.empty |
58 | 75 | else |
59 | | - match warning.error with |
60 | | - | Warn_error_true -> |
| 76 | + match warning.error with |
| 77 | + | Warn_error_true -> |
61 | 78 | warn_error |
62 | 79 |
|
63 | | - | Warn_error_number y -> |
| 80 | + | Warn_error_number y -> |
64 | 81 | " -warn-error " ^ y |
65 | | - | Warn_error_false -> |
66 | | - Ext_string.empty |
| 82 | + | Warn_error_false -> |
| 83 | + Ext_string.empty |
67 | 84 |
|
68 | 85 |
|
69 | 86 |
|
70 | | -let from_map (m : Ext_json_types.t String_map.t) = |
71 | | - let number_opt = String_map.find_opt Bsb_build_schemas.number m in |
72 | | - let error_opt = String_map.find_opt Bsb_build_schemas.error m in |
73 | | - match number_opt, error_opt with |
| 87 | +let from_map (m : Ext_json_types.t String_map.t) = |
| 88 | + let number_opt = String_map.find_opt Bsb_build_schemas.number m in |
| 89 | + let error_opt = String_map.find_opt Bsb_build_schemas.error m in |
| 90 | + match number_opt, error_opt with |
74 | 91 | | None, None -> None |
75 | | - | _, _ -> |
76 | | - let error = |
77 | | - match error_opt with |
| 92 | + | _, _ -> |
| 93 | + let error = |
| 94 | + match error_opt with |
78 | 95 | | Some (True _) -> Warn_error_true |
79 | 96 | | Some (False _) -> Warn_error_false |
80 | | - | Some (Str {str ; }) |
81 | | - -> Warn_error_number str |
| 97 | + | Some (Str {str ; }) |
| 98 | + -> Warn_error_number str |
82 | 99 | | Some x -> Bsb_exception.config_error x "expect true/false or string" |
83 | 100 | | None -> Warn_error_false |
84 | | - (** To make it less intrusive : warning error has to be enabled*) |
| 101 | + (** To make it less intrusive : warning error has to be enabled*) |
85 | 102 | in |
86 | | - let number = |
87 | | - match number_opt with |
| 103 | + let number = |
| 104 | + match number_opt with |
88 | 105 | | Some (Str { str = number}) -> Some number |
89 | | - | None -> None |
90 | | - | Some x -> Bsb_exception.config_error x "expect a string" |
91 | | - in |
92 | | - Some {number; error } |
| 106 | + | None -> None |
| 107 | + | Some x -> Bsb_exception.config_error x "expect a string" |
| 108 | + in |
| 109 | + Some {number; error } |
93 | 110 |
|
94 | | -let opt_warning_to_string not_dev warning = |
95 | | - match warning with |
| 111 | +let opt_warning_to_string not_dev warning = |
| 112 | + match warning with |
96 | 113 | | None -> default_warning_flag |
97 | | - | Some w -> warning_to_string not_dev w |
| 114 | + | Some w -> warning_to_string not_dev w |
98 | 115 |
|
0 commit comments