@@ -29,70 +29,25 @@ type warning_error =
2929 | Warn_error_true
3030 | Warn_error_number of string
3131
32- type t = {
32+ type t0 = {
3333 number : string option ;
3434 error : warning_error
3535}
3636
37- (* *
38- See the meanings of the warning codes here: https://caml.inria.fr/pub/docs/manual-ocaml/comp.html#sec281
37+ type nonrec t = t0 option
3938
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.
39+ let use_default = None
4240
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- *)
54- let default_warning = " -30-40+6+7+27+32..39+44+45+101"
55-
56- let default_warning_flag = " -w " ^ default_warning
57-
58- let get_warning_flag x =
59- default_warning_flag ^
41+ let to_merlin_string x =
42+ " -w " ^ Bsc_warnings. defaults_w
43+ ^
6044 (match x with
6145 | Some {number = None }
6246 | None -> Ext_string. empty
6347 | Some {number = Some x } -> Ext_string. trim x )
6448
6549
66- let warn_error = " -warn-error A"
67-
68- let warning_to_string ~toplevel
69- warning : string =
70- default_warning_flag ^
71- (match warning.number with
72- | None ->
73- Ext_string. empty
74- | Some x ->
75- let content =
76- Ext_string. trim x in
77- if content = " " then content
78- else
79- match content.[0 ] with
80- | '0' .. '9' -> " +" ^ content
81- | _ -> content
82- ) ^
83- if toplevel then
84- match warning.error with
85- | Warn_error_true ->
86- warn_error
87-
88- | Warn_error_number y ->
89- " -warn-error " ^ y
90- | Warn_error_false ->
91- Ext_string. empty
92- else Ext_string. empty
93-
94-
95-
50+
9651let from_map (m : Ext_json_types.t Map_string.t ) =
9752 let number_opt = Map_string. find_opt m Bsb_build_schemas. number in
9853 let error_opt = Map_string. find_opt m Bsb_build_schemas. error in
@@ -117,8 +72,30 @@ let from_map (m : Ext_json_types.t Map_string.t) =
11772 in
11873 Some {number; error }
11974
120- let opt_warning_to_string ~toplevel warning =
75+ let to_bsb_string ~toplevel warning =
12176 match warning with
122- | None -> default_warning_flag
123- | Some w -> warning_to_string ~toplevel w
77+ | None -> Ext_string. empty
78+ | Some warning ->
79+ " -w " ^ Bsc_warnings. defaults_w ^
80+ (match warning.number with
81+ | None ->
82+ Ext_string. empty
83+ | Some x ->
84+ let content =
85+ Ext_string. trim x in
86+ if content = " " then content
87+ else
88+ match content.[0 ] with
89+ | '0' .. '9' -> " +" ^ content
90+ | _ -> content
91+ ) ^
92+ if toplevel then
93+ match warning.error with
94+ | Warn_error_true ->
95+ " -warn-error A"
96+ | Warn_error_number y ->
97+ " -warn-error " ^ y
98+ | Warn_error_false ->
99+ Ext_string. empty
100+ else Ext_string. empty
124101
0 commit comments