Skip to content

Commit 642dd6a

Browse files
authored
[Playground][JSX PPX] Tweaks to warnings & errors (#2720)
* [Playground][JSX PPX] Tweaks to warnings & errors - Make warnings use super-errors too - Add default warnings set from bsb (cc @astrada, no more ReasonReact warning 40 that you have to grep out anymore!) - Report errors into stderr (aka console.error) * Share the warning numbers * Check in deps graph
1 parent ce71910 commit 642dd6a

File tree

6 files changed

+43
-11
lines changed

6 files changed

+43
-11
lines changed

jscomp/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ bin/jsoo_reactjs_jsx_ppx_v2.ml:./bin/reactjs_jsx_ppx_v2.bspp.ml ../lib/bspp.exe
559559
BS_COMPILER_IN_BROWSER=true ../lib/bspp.exe $^ > $@
560560

561561
bin/js_compiler.ml:./bin/bspack.exe
562-
./bin/bspack.exe -D BS_COMPILER_IN_BROWSER=true -U BS_DEBUG -bs-MD -module-alias Config=Config_whole_compiler -bs-exclude-I config -o $@ -bs-main Jsoo_main -I $(OCAML_SRC_UTILS) -I $(OCAML_SRC_PARSING) -I $(OCAML_SRC_TYPING) -I $(OCAML_SRC_BYTECOMP) -I $(OCAML_SRC_DRIVER) -I stubs -I ext -I syntax -I depends -I common -I core -I super_errors -I outcome_printer
562+
./bin/bspack.exe -D BS_COMPILER_IN_BROWSER=true -U BS_DEBUG -bs-MD -module-alias Config=Config_whole_compiler -bs-exclude-I config -o $@ -bs-main Jsoo_main -I $(OCAML_SRC_UTILS) -I $(OCAML_SRC_PARSING) -I $(OCAML_SRC_TYPING) -I $(OCAML_SRC_BYTECOMP) -I $(OCAML_SRC_DRIVER) -I stubs -I ext -I syntax -I depends -I common -I core -I super_errors -I bsb -I outcome_printer
563563

564564
bin/all_ounit_tests.ml:./bin/bspack.exe
565565
$< -bs-MD -I ounit -I ounit_tests -I stubs -I bsb -I common -I ext -I syntax -I depends -I bspp -I core -bs-main Ounit_tests_main -o $@

jscomp/bin/js_compiler.d

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ bin/js_compiler.ml : ./core/js_long.ml
2222
bin/js_compiler.ml : ./core/lam_dce.ml
2323
bin/js_compiler.ml : ./ext/ext_char.ml
2424
bin/js_compiler.ml : ./ext/ext_int.mli
25+
bin/js_compiler.ml : ./ext/ext_json.ml
2526
bin/js_compiler.ml : ./ext/ext_list.ml
2627
bin/js_compiler.ml : ./ext/ext_path.ml
2728
bin/js_compiler.ml : ./ext/ext_ref.mli
@@ -43,6 +44,7 @@ bin/js_compiler.ml : ./ext/ext_array.ml
4344
bin/js_compiler.ml : ./ext/ext_bytes.ml
4445
bin/js_compiler.ml : ./ext/ext_char.mli
4546
bin/js_compiler.ml : ./ext/ext_ident.ml
47+
bin/js_compiler.ml : ./ext/ext_json.mli
4648
bin/js_compiler.ml : ./ext/ext_list.mli
4749
bin/js_compiler.ml : ./ext/ext_path.mli
4850
bin/js_compiler.ml : ./ext/ext_utf8.mli
@@ -73,6 +75,7 @@ bin/js_compiler.ml : ./ext/ident_set.mli
7375
bin/js_compiler.ml : ./ext/string_map.ml
7476
bin/js_compiler.ml : ./syntax/ast_exp.ml
7577
bin/js_compiler.ml : ./syntax/ast_pat.ml
78+
bin/js_compiler.ml : ./bsb/bsb_warning.ml
7679
bin/js_compiler.ml : ./common/ext_log.mli
7780
bin/js_compiler.ml : ./core/js_closure.ml
7881
bin/js_compiler.ml : ./core/js_fun_env.ml
@@ -96,6 +99,7 @@ bin/js_compiler.ml : ./syntax/ast_exp.mli
9699
bin/js_compiler.ml : ./syntax/ast_pat.mli
97100
bin/js_compiler.ml : ./syntax/ast_util.ml
98101
bin/js_compiler.ml : ../vendor/ocaml/utils/tbl.ml
102+
bin/js_compiler.ml : ./bsb/bsb_warning.mli
99103
bin/js_compiler.ml : ./common/js_config.ml
100104
bin/js_compiler.ml : ./core/config_util.ml
101105
bin/js_compiler.ml : ./core/js_analyzer.ml
@@ -127,6 +131,7 @@ bin/js_compiler.ml : ./syntax/ppx_entry.ml
127131
bin/js_compiler.ml : ../vendor/ocaml/typing/env.ml
128132
bin/js_compiler.ml : ../vendor/ocaml/utils/misc.ml
129133
bin/js_compiler.ml : ../vendor/ocaml/utils/tbl.mli
134+
bin/js_compiler.ml : ./bsb/bsb_exception.ml
130135
bin/js_compiler.ml : ./common/bs_version.ml
131136
bin/js_compiler.ml : ./common/js_config.mli
132137
bin/js_compiler.ml : ./core/config_util.mli
@@ -157,7 +162,9 @@ bin/js_compiler.ml : ./syntax/ast_tdcls.mli
157162
bin/js_compiler.ml : ./syntax/ppx_entry.mli
158163
bin/js_compiler.ml : ../vendor/ocaml/typing/env.mli
159164
bin/js_compiler.ml : ../vendor/ocaml/typing/path.ml
165+
bin/js_compiler.ml : ../vendor/ocaml/utils/ccomp.ml
160166
bin/js_compiler.ml : ../vendor/ocaml/utils/misc.mli
167+
bin/js_compiler.ml : ./bsb/bsb_exception.mli
161168
bin/js_compiler.ml : ./common/bs_version.mli
162169
bin/js_compiler.ml : ./common/bs_warnings.ml
163170
bin/js_compiler.ml : ./core/js_call_info.mli
@@ -189,6 +196,7 @@ bin/js_compiler.ml : ../vendor/ocaml/typing/mtype.ml
189196
bin/js_compiler.ml : ../vendor/ocaml/typing/path.mli
190197
bin/js_compiler.ml : ../vendor/ocaml/typing/subst.ml
191198
bin/js_compiler.ml : ../vendor/ocaml/typing/types.ml
199+
bin/js_compiler.ml : ../vendor/ocaml/utils/ccomp.mli
192200
bin/js_compiler.ml : ./common/bs_warnings.mli
193201
bin/js_compiler.ml : ./common/lam_methname.ml
194202
bin/js_compiler.ml : ./core/js_cmj_format.mli
@@ -211,6 +219,7 @@ bin/js_compiler.ml : ./syntax/ast_literal.mli
211219
bin/js_compiler.ml : ./syntax/ast_payload.mli
212220
bin/js_compiler.ml : ./syntax/ast_polyvar.mli
213221
bin/js_compiler.ml : ./syntax/bs_syntaxerr.ml
222+
bin/js_compiler.ml : ../vendor/ocaml/driver/pparse.ml
214223
bin/js_compiler.ml : ../vendor/ocaml/parsing/lexer.ml
215224
bin/js_compiler.ml : ../vendor/ocaml/parsing/parse.ml
216225
bin/js_compiler.ml : ../vendor/ocaml/typing/annot.mli
@@ -248,6 +257,7 @@ bin/js_compiler.ml : ./syntax/ast_structure.ml
248257
bin/js_compiler.ml : ./syntax/bs_ast_mapper.ml
249258
bin/js_compiler.ml : ./syntax/bs_syntaxerr.mli
250259
bin/js_compiler.ml : ../vendor/ocaml/driver/compenv.ml
260+
bin/js_compiler.ml : ../vendor/ocaml/driver/pparse.mli
251261
bin/js_compiler.ml : ../vendor/ocaml/parsing/lexer.mli
252262
bin/js_compiler.ml : ../vendor/ocaml/parsing/parse.mli
253263
bin/js_compiler.ml : ../vendor/ocaml/parsing/parser.ml
@@ -258,6 +268,7 @@ bin/js_compiler.ml : ../vendor/ocaml/typing/typemod.ml
258268
bin/js_compiler.ml : ../vendor/ocaml/utils/clflags.mli
259269
bin/js_compiler.ml : ../vendor/ocaml/utils/terminfo.ml
260270
bin/js_compiler.ml : ../vendor/ocaml/utils/warnings.ml
271+
bin/js_compiler.ml : ./bsb/bsb_build_schemas.ml
261272
bin/js_compiler.ml : ./core/js_cmj_datasets.mli
262273
bin/js_compiler.ml : ./core/js_dump_program.mli
263274
bin/js_compiler.ml : ./core/js_dump_property.ml
@@ -318,6 +329,7 @@ bin/js_compiler.ml : ./core/lam_module_ident.mli
318329
bin/js_compiler.ml : ./core/lam_pass_collect.mli
319330
bin/js_compiler.ml : ./core/lam_pass_lets_dce.ml
320331
bin/js_compiler.ml : ./core/lam_stats_export.mli
332+
bin/js_compiler.ml : ./super_errors/super_env.ml
321333
bin/js_compiler.ml : ./syntax/ast_attributes.mli
322334
bin/js_compiler.ml : ./syntax/ast_derive_util.ml
323335
bin/js_compiler.ml : ./syntax/ast_external_mk.ml
@@ -346,6 +358,8 @@ bin/js_compiler.ml : ./core/lam_compile_global.ml
346358
bin/js_compiler.ml : ./core/lam_eta_conversion.ml
347359
bin/js_compiler.ml : ./core/lam_pass_lets_dce.mli
348360
bin/js_compiler.ml : ./ext/hash_set_ident_mask.ml
361+
bin/js_compiler.ml : ./super_errors/super_main.ml
362+
bin/js_compiler.ml : ./super_errors/super_misc.ml
349363
bin/js_compiler.ml : ./syntax/ast_derive_util.mli
350364
bin/js_compiler.ml : ./syntax/ast_external_mk.mli
351365
bin/js_compiler.ml : ./syntax/ast_utf8_string.mli
@@ -370,6 +384,7 @@ bin/js_compiler.ml : ./core/lam_compile_global.mli
370384
bin/js_compiler.ml : ./core/lam_eta_conversion.mli
371385
bin/js_compiler.ml : ./ext/hash_set_ident_mask.mli
372386
bin/js_compiler.ml : ./ext/ordered_hash_map_gen.ml
387+
bin/js_compiler.ml : ./super_errors/super_misc.mli
373388
bin/js_compiler.ml : ./syntax/ast_exp_extension.ml
374389
bin/js_compiler.ml : ./syntax/bs_ast_invariant.mli
375390
bin/js_compiler.ml : ./syntax/external_arg_spec.ml
@@ -391,6 +406,7 @@ bin/js_compiler.ml : ./core/js_name_of_module_id.ml
391406
bin/js_compiler.ml : ./core/js_of_lam_exception.mli
392407
bin/js_compiler.ml : ./core/lam_beta_reduce_util.ml
393408
bin/js_compiler.ml : ./core/lam_compile_context.mli
409+
bin/js_compiler.ml : ./super_errors/super_pparse.ml
394410
bin/js_compiler.ml : ./syntax/ast_exp_extension.mli
395411
bin/js_compiler.ml : ./syntax/external_arg_spec.mli
396412
bin/js_compiler.ml : ./syntax/external_ffi_types.ml
@@ -411,6 +427,7 @@ bin/js_compiler.ml : ./core/lam_beta_reduce_util.mli
411427
bin/js_compiler.ml : ./core/lam_compile_primitive.ml
412428
bin/js_compiler.ml : ./core/lam_pass_deep_flatten.ml
413429
bin/js_compiler.ml : ./core/lam_pass_remove_alias.ml
430+
bin/js_compiler.ml : ./super_errors/super_typemod.ml
414431
bin/js_compiler.ml : ./syntax/ast_derive_abstract.ml
415432
bin/js_compiler.ml : ./syntax/external_ffi_types.mli
416433
bin/js_compiler.ml : ../vendor/ocaml/bytecomp/printlambda.ml
@@ -427,6 +444,10 @@ bin/js_compiler.ml : ./core/lam_dispatch_primitive.ml
427444
bin/js_compiler.ml : ./core/lam_pass_deep_flatten.mli
428445
bin/js_compiler.ml : ./core/lam_pass_eliminate_ref.ml
429446
bin/js_compiler.ml : ./core/lam_pass_remove_alias.mli
447+
bin/js_compiler.ml : ./super_errors/super_location.ml
448+
bin/js_compiler.ml : ./super_errors/super_typecore.ml
449+
bin/js_compiler.ml : ./super_errors/super_typetexp.ml
450+
bin/js_compiler.ml : ./super_errors/super_warnings.ml
430451
bin/js_compiler.ml : ./syntax/ast_derive_abstract.mli
431452
bin/js_compiler.ml : ./syntax/ast_derive_js_mapper.ml
432453
bin/js_compiler.ml : ./syntax/ast_derive_projector.ml
@@ -448,8 +469,10 @@ bin/js_compiler.ml : ./core/lam_pass_alpha_conversion.ml
448469
bin/js_compiler.ml : ./syntax/ast_utf8_string_interp.mli
449470
bin/js_compiler.ml : ./core/lam_compile_external_call.mli
450471
bin/js_compiler.ml : ./core/lam_pass_alpha_conversion.mli
472+
bin/js_compiler.ml : ./super_errors/super_reason_react.ml
451473
bin/js_compiler.ml : ./syntax/ast_core_type_class_type.ml
452474
bin/js_compiler.ml : ./ext/ordered_hash_map_local_ident.ml
475+
bin/js_compiler.ml : ./super_errors/super_reason_react.mli
453476
bin/js_compiler.ml : ./syntax/ast_core_type_class_type.mli
454477
bin/js_compiler.ml : ./syntax/ast_tuple_pattern_flatten.ml
455478
bin/js_compiler.ml : ./ext/ordered_hash_map_local_ident.mli

jscomp/bin/reactjs_jsx_ppx_v2.bspp.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ let rewrite code =
346346
with e ->
347347
match Location.error_of_exn e with
348348
| Some error ->
349-
Location.report_error Format.std_formatter error;
349+
Location.report_error Format.err_formatter error;
350350
let (file, line, startchar) = Location.get_pos_info error.loc.loc_start in
351351
let (file, endline, endchar) = Location.get_pos_info error.loc.loc_end in
352352
Js.Unsafe.(obj

jscomp/bsb/bsb_warning.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ type t = {
5151
- 48 Implicit elimination of optional arguments. https://caml.inria.fr/mantis/view.php?id=6352
5252
- 101 (bsb-specific) unsafe polymorphic comparison.
5353
*)
54-
let default_warning_flag = "-w -30-40+6+7+27+32..39+44+45+101"
54+
let default_warning = "-30-40+6+7+27+32..39+44+45+101"
55+
56+
let default_warning_flag = "-w " ^ default_warning
5557

5658
let get_warning_flag x =
5759
default_warning_flag ^

jscomp/bsb/bsb_warning.mli

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,18 @@
2525

2626

2727

28-
type t
28+
type t
2929

30-
val get_warning_flag : t option -> string
30+
val get_warning_flag : t option -> string
31+
32+
val default_warning : string
3133

3234
val default_warning_flag : string
35+
(* default_warning, including the -w prefix, for command-line arguments *)
3336

3437
val from_map : Ext_json_types.t String_map.t -> t option
3538

3639
(** [opt_warning_to_string not_dev warning]
3740
*)
38-
val opt_warning_to_string : bool -> t option -> string
41+
val opt_warning_to_string : bool -> t option -> string
3942

jscomp/core/jsoo_main.ml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ let implementation ~use_super_errors prefix impl str : Js.Unsafe.obj =
7575
let env = Compmisc.initial_env() in (* Question ?? *)
7676
let finalenv = ref Env.empty in
7777
let types_signature = ref [] in
78+
if use_super_errors then begin
79+
Misc.Color.setup Clflags.Always;
80+
Super_main.setup ();
81+
end;
82+
83+
(* copied over from Bsb_warning.default_warning_flag *)
84+
Warnings.parse_options false Bsb_warning.default_warning;
85+
7886
try
7987
impl (Lexing.from_string
8088
(if prefix then "[@@@bs.config{no_export}]\n#1 \"repl.ml\"\n" ^ str else str ))
@@ -99,13 +107,9 @@ let implementation ~use_super_errors prefix impl str : Js.Unsafe.obj =
99107
(* Format.fprintf output_ppf {| { "js_code" : %S }|} v ) *)
100108
with
101109
| e ->
102-
if use_super_errors then begin
103-
Misc.Color.setup Clflags.Always;
104-
Super_main.setup ();
105-
end;
106110
begin match Location.error_of_exn e with
107111
| Some error ->
108-
Location.report_error Format.std_formatter error;
112+
Location.report_error Format.err_formatter error;
109113
let (file,line,startchar) = Location.get_pos_info error.loc.loc_start in
110114
let (file,endline,endchar) = Location.get_pos_info error.loc.loc_end in
111115
Js.Unsafe.(obj

0 commit comments

Comments
 (0)