2323 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424
2525
26+ type warning_error =
27+ | Warn_error_false
28+ (* default [false] to make our changes non-intrusive *)
29+ | Warn_error_true
30+ | Warn_error_number of string
2631
2732type t0 = {
28- number : string option ;
29- } [@@ ocaml.unboxed]
33+ number : string option ;
34+ error : warning_error
35+ }
3036
3137type nonrec t = t0 option
3238
@@ -64,13 +70,27 @@ let to_merlin_string x =
6470
6571let from_map (m : Ext_json_types.t Map_string.t ) =
6672 let number_opt = Map_string. find_opt m Bsb_build_schemas. number in
67- let number =
68- match number_opt with
69- | Some (Str { str = number } ) -> Some number
70- | None -> None
71- | Some x -> Bsb_exception. config_error x " expect a string"
72- in
73- Some {number }
73+ let error_opt = Map_string. find_opt m Bsb_build_schemas. error in
74+ match number_opt, error_opt with
75+ | None , None -> None
76+ | _ , _ ->
77+ let error =
78+ match error_opt with
79+ | Some (True _ ) -> Warn_error_true
80+ | Some (False _ ) -> Warn_error_false
81+ | Some (Str {str ; })
82+ -> Warn_error_number str
83+ | Some x -> Bsb_exception. config_error x " expect true/false or string"
84+ | None -> Warn_error_false
85+ (* * To make it less intrusive : warning error has to be enabled*)
86+ in
87+ let number =
88+ match number_opt with
89+ | Some (Str { str = number } ) -> Some number
90+ | None -> None
91+ | Some x -> Bsb_exception. config_error x " expect a string"
92+ in
93+ Some {number; error }
7494
7595
7696let to_bsb_string ~toplevel warning =
@@ -83,6 +103,15 @@ let to_bsb_string ~toplevel warning =
83103 Ext_string. empty
84104 | Some x ->
85105 prepare_warning_concat ~beg: true x
86- )
106+ ) ^
107+ (
108+ match warning.error with
109+ | Warn_error_true ->
110+ " -warn-error A"
111+ | Warn_error_number y ->
112+ " -warn-error " ^ y
113+ | Warn_error_false ->
114+ Ext_string. empty
115+ )
87116 else " -w a"
88117 (* TODO: this is the current default behavior *)
0 commit comments