Skip to content

Commit 50d60fe

Browse files
authored
Merge pull request #4122 from BuckleScript/move_bs_only_to_config
make @warning switch applicable to bucklescript warnings, remove customized warnings to use ocaml's own warning number
2 parents f0997d8 + f24fd37 commit 50d60fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+10834
-10427
lines changed

jscomp/bsb/bsb_build_schemas.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

2525

26-
let files = "files"
26+
(* let files = "files" *)
2727
let version = "version"
2828
let name = "name"
2929
(* let ocaml_config = "ocaml-config" *)

jscomp/bsb/bsb_file.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ let install_if_exists ~destdir input_name =
3838
if Sys.file_exists input_name then
3939
let output_name = (Filename.concat destdir (Filename.basename input_name)) in
4040
match Unix.stat output_name , Unix.stat input_name with
41-
| {st_mtime = output_stamp}, {st_mtime = input_stamp} when input_stamp <= output_stamp
41+
| {st_mtime = output_stamp;_}, {st_mtime = input_stamp;_} when input_stamp <= output_stamp
4242
-> false
4343
| _ -> copy_with_permission input_name output_name; true
4444
| exception _ -> copy_with_permission input_name output_name; true

jscomp/bsb/bsb_global_paths.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ val vendor_bsdep : string
3535

3636
val vendor_bsppx : string
3737

38-
val vendor_bsppx : string
39-
4038
val ocaml_dir : string
4139

4240
val ocaml_lib_dir : string

jscomp/bsb/bsb_ninja_gen.ml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@ let dash_i = "-I"
3636

3737

3838
let get_bsc_flags
39-
~(toplevel : bool)
4039
(bsc_flags : string list)
4140
: string =
42-
String.concat Ext_string.single_space
43-
(if toplevel then bsc_flags else "-bs-quiet" :: bsc_flags )
41+
String.concat Ext_string.single_space bsc_flags
42+
4443

4544

4645
let emit_bsc_lib_includes
@@ -160,7 +159,7 @@ let output_ninja_and_namespace_map
160159
(* The path to [bsb_heler.exe] *)
161160
Bsb_ninja_global_vars.bsdep, (Ext_filename.maybe_quote Bsb_global_paths.vendor_bsdep) ;
162161
Bsb_ninja_global_vars.warnings, Bsb_warning.to_bsb_string ~toplevel warning ;
163-
Bsb_ninja_global_vars.bsc_flags, (get_bsc_flags ~toplevel bsc_flags) ;
162+
Bsb_ninja_global_vars.bsc_flags, (get_bsc_flags bsc_flags) ;
164163
Bsb_ninja_global_vars.ppx_flags, ppx_flags;
165164

166165
Bsb_ninja_global_vars.g_dpkg_incls,

jscomp/bsb/bsb_warning.ml

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,26 @@ let from_map (m : Ext_json_types.t Map_string.t) =
8686
in
8787
Some {number; error }
8888

89-
let to_bsb_string ~toplevel warning =
90-
match warning with
91-
| None -> Ext_string.empty
92-
| Some warning ->
93-
(match warning.number with
94-
| None ->
95-
Ext_string.empty
96-
| Some x ->
97-
prepare_warning_concat ~beg:true x
98-
) ^
99-
if toplevel then
100-
match warning.error with
101-
| Warn_error_true ->
102-
" -warn-error A"
103-
| Warn_error_number y ->
104-
" -warn-error " ^ y
105-
| Warn_error_false ->
106-
Ext_string.empty
107-
else Ext_string.empty
10889

90+
let to_bsb_string ~toplevel warning =
91+
if toplevel then
92+
match warning with
93+
| None -> Ext_string.empty
94+
| Some warning ->
95+
(match warning.number with
96+
| None ->
97+
Ext_string.empty
98+
| Some x ->
99+
prepare_warning_concat ~beg:true x
100+
) ^
101+
(
102+
match warning.error with
103+
| Warn_error_true ->
104+
" -warn-error A"
105+
| Warn_error_number y ->
106+
" -warn-error " ^ y
107+
| Warn_error_false ->
108+
Ext_string.empty
109+
)
110+
else " -w a"
111+
(* TODO: this is the current default behavior *)

jscomp/bsb_helper/bsb_helper_arg.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type spec =
1313
| Set_int of int ref
1414

1515
exception Bad of string
16-
exception Help of string
16+
(* exception Help of string *)
1717

1818
type error =
1919
| Unknown of string
@@ -29,14 +29,14 @@ type t = (string * spec * string) list
2929
let rec assoc3 (x : string) (l : t) =
3030
match l with
3131
| [] -> None
32-
| (y1, y2, y3) :: t when y1 = x -> Some y2
32+
| (y1, y2, _y3) :: _t when y1 = x -> Some y2
3333
| _ :: t -> assoc3 x t
3434
;;
3535

3636

3737

3838
let usage_b (buf : Ext_buffer.t) speclist errmsg =
39-
let print_spec buf (key, spec, doc) =
39+
let print_spec buf (key, _spec, doc) =
4040
if doc <> "" then begin
4141
Ext_buffer.add_string buf " ";
4242
Ext_buffer.add_string_char buf key ' ';
@@ -100,7 +100,7 @@ let parse_exn (speclist : t) anonfun errmsg =
100100
| None -> stop_raise (Unknown s)
101101
in
102102
begin try
103-
let rec treat_action = function
103+
let treat_action = function
104104
| Unit f -> f ();
105105
| Set r -> r := true;
106106
| String f when !current + 1 < l ->

jscomp/common/bs_loc.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ let merge (l: t) (r : t) =
3535
if is_ghost l then r
3636
else if is_ghost r then l
3737
else match l,r with
38-
| {loc_start ; }, {loc_end; _} (* TODO: improve*)
38+
| {loc_start ; _}, {loc_end; _} (* TODO: improve*)
3939
->
4040
{loc_start ;loc_end; loc_ghost = false}
4141

jscomp/common/bs_warnings.ml

Lines changed: 7 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -39,92 +39,25 @@ let to_string t =
3939
->
4040
"Here a OCaml polymorphic variant type passed into JS, probably you forgot annotations like `[@bs.int]` or `[@bs.string]` "
4141

42-
let warning_formatter = Format.err_formatter
43-
44-
let print_string_warning (loc : Location.t) x =
45-
if loc.loc_ghost then
46-
Format.fprintf warning_formatter "File %s@." !Location.input_name
47-
else
48-
Location.print warning_formatter loc ;
49-
Format.fprintf warning_formatter "@{<error>Warning@}: %s@." x
5042

5143
let prerr_bs_ffi_warning loc x =
52-
Location.prerr_warning loc (Warnings.Bs_ffi_warning (to_string x))
53-
54-
let unimplemented_primitive = "Unimplemented primitive used:"
55-
type error =
56-
| Uninterpreted_delimiters of string
57-
| Unimplemented_primitive of string
58-
exception Error of Location.t * error
59-
60-
let pp_error fmt x =
61-
match x with
62-
| Unimplemented_primitive str ->
63-
Format.pp_print_string fmt unimplemented_primitive;
64-
Format.pp_print_string fmt str
65-
66-
| Uninterpreted_delimiters str ->
67-
Format.pp_print_string fmt "Uninterpreted delimiters" ;
68-
Format.pp_print_string fmt str
69-
70-
44+
Location.prerr_warning loc (Bs_ffi_warning (to_string x))
7145

72-
let () =
73-
Location.register_error_of_exn (function
74-
| Error (loc,err) ->
75-
Some (Location.error_of_printer loc pp_error err)
76-
| _ -> None
77-
)
7846

7947

8048

8149

82-
let warn_missing_primitive loc txt =
83-
if not !Js_config.no_warn_unimplemented_external && not !Clflags.bs_quiet then
84-
begin
85-
print_string_warning loc ( unimplemented_primitive ^ txt ^ " \n" );
86-
Format.pp_print_flush warning_formatter ()
87-
end
50+
let warn_missing_primitive loc txt =
51+
Location.prerr_warning loc (Bs_unimplemented_primitive txt)
8852

8953
let warn_literal_overflow loc =
90-
if not !Clflags.bs_quiet then
91-
begin
92-
print_string_warning loc
93-
"Integer literal exceeds the range of representable integers of type int";
94-
Format.pp_print_flush warning_formatter ()
95-
end
54+
Location.prerr_warning loc Bs_integer_literal_overflow
9655

9756

9857

9958
let error_unescaped_delimiter loc txt =
100-
raise (Error(loc, Uninterpreted_delimiters txt))
101-
102-
103-
104-
105-
106-
107-
(**
108-
Note the standard way of reporting error in compiler:
109-
110-
val Location.register_error_of_exn : (exn -> Location.error option) -> unit
111-
val Location.error_of_printer : Location.t ->
112-
(Format.formatter -> error -> unit) -> error -> Location.error
113-
114-
Define an error type
115-
116-
type error
117-
exception Error of Location.t * error
59+
Location.prerr_warning loc (Bs_uninterpreted_delimiters txt)
60+
11861

119-
Provide a printer to error
12062

121-
{[
122-
let () =
123-
Location.register_error_of_exn
124-
(function
125-
| Error(loc,err) ->
126-
Some (Location.error_of_printer loc pp_error err)
127-
| _ -> None
128-
)
129-
]}
130-
*)
63+

jscomp/common/js_config.ml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,14 @@ let diagnose = ref false
6161
let get_diagnose () = !diagnose
6262
let set_diagnose b = diagnose := b
6363

64-
let (//) = Filename.concat
64+
(* let (//) = Filename.concat *)
6565

6666
(* let get_packages_info () = !packages_info *)
6767

6868
let no_builtin_ppx_ml = ref false
6969
let no_builtin_ppx_mli = ref false
7070

7171

72-
(** TODO: will flip the option when it is ready *)
73-
let no_warn_unimplemented_external = ref false
74-
7572
let debug_file = ref ""
7673

7774

jscomp/common/js_config.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ val no_builtin_ppx_mli : bool ref
6363

6464

6565

66-
val no_warn_unimplemented_external : bool ref
66+
6767

6868
(** check-div-by-zero option *)
6969
val check_div_by_zero : bool ref

0 commit comments

Comments
 (0)