Skip to content

Commit 277f153

Browse files
committed
more verbose labels
1 parent 4a5190a commit 277f153

17 files changed

+280
-108
lines changed

Diff for: jscomp/all.depend

+3-1
Original file line numberDiff line numberDiff line change
@@ -761,9 +761,11 @@ super_errors/super_main.cmx : super_errors/super_typetexp.cmx \
761761
super_errors/super_env.cmx
762762
super_errors/super_reason_react.cmi :
763763
super_errors/super_misc.cmi :
764+
outcome_printer/reason_syntax_util.cmx :
764765
outcome_printer/outcome_printer_ns.cmx : ext/ext_namespace.cmx \
765766
outcome_printer/outcome_printer_ns.cmi
766-
outcome_printer/tweaked_reason_oprint.cmx :
767+
outcome_printer/tweaked_reason_oprint.cmx : \
768+
outcome_printer/reason_syntax_util.cmx
767769
outcome_printer/reason_outcome_printer_main.cmx : \
768770
outcome_printer/tweaked_reason_oprint.cmx
769771
outcome_printer/outcome_printer_ns.cmi :

Diff for: jscomp/core/bs_conditional_initial.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
let setup_env () =
2727
#if BS_DEBUG then
28-
Js_config.set_debug_file "gpr_2352_test.ml";
28+
Js_config.set_debug_file "gpr_2413_test.ml";
2929
#end
3030
Lexer.replace_directive_bool "BS" true;
3131
Lexer.replace_directive_string "BS_VERSION" Bs_version.version

Diff for: jscomp/core/j.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,8 @@ and variable_declaration = {
379379
}
380380

381381
and 'a case_clause = {
382-
case : 'a ;
383-
body : block * bool ; (* true means break *)
382+
switch_case : 'a ;
383+
switch_body : block * bool ; (* true means break *)
384384
}
385385

386386
(* TODO: For efficency: block should not be a list, it should be able to

Diff for: jscomp/core/js_dump.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ and pp_function method_
359359
and output_one : 'a .
360360
_ -> P.t -> (P.t -> 'a -> unit) -> 'a J.case_clause -> _
361361
= fun cxt f pp_cond
362-
({case = e; body = (sl,break)} : _ J.case_clause) ->
362+
({switch_case = e; switch_body = (sl,should_break)} : _ J.case_clause) ->
363363
let cxt =
364364
P.group f 1 @@ fun _ ->
365365
P.group f 1 @@ (fun _ ->
@@ -378,7 +378,7 @@ and output_one : 'a .
378378
P.newline f ;
379379
statement_list false cxt f sl
380380
in
381-
(if break then
381+
(if should_break then
382382
begin
383383
P.newline f ;
384384
P.string f L.break;

Diff for: jscomp/core/js_fold.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ class virtual fold =
461461
{[ goto : label option ; ]}
462462
*)
463463
'a. ('self_type -> 'a -> 'self_type) -> 'a case_clause -> 'self_type =
464-
fun _f_a { case = _x; body = _x_i1 } ->
464+
fun _f_a { switch_case = _x; switch_body = _x_i1 } ->
465465
let o = _f_a o _x in
466466
let o =
467467
(fun (_x, _x_i1) -> let o = o#block _x in let o = o#bool _x_i1 in o)

Diff for: jscomp/core/js_map.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -512,13 +512,13 @@ class virtual map =
512512
*)
513513
'a 'a_out.
514514
('self_type -> 'a -> 'a_out) -> 'a case_clause -> 'a_out case_clause =
515-
fun _f_a { case = _x; body = _x_i1 } ->
515+
fun _f_a { switch_case = _x; switch_body = _x_i1 } ->
516516
let _x = _f_a o _x in
517517
let _x_i1 =
518518
(fun (_x, _x_i1) ->
519519
let _x = o#block _x in let _x_i1 = o#bool _x_i1 in (_x, _x_i1))
520520
_x_i1
521-
in { case = _x; body = _x_i1; }
521+
in { switch_case = _x; switch_body = _x_i1; }
522522
method block : block -> block = (* true means break *)
523523
(* TODO: For efficency: block should not be a list, it should be able to
524524
be concatenated in both ways

Diff for: jscomp/core/js_of_lam_variant.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ let eval (arg : J.expression) (dispatches : (int * string) list ) : E.t =
4040
E.of_block
4141
[(S.int_switch arg
4242
(Ext_list.map (fun (i,r) ->
43-
{J.case = i ;
44-
body = [S.return_stmt (E.str r)],
43+
{J.switch_case = i ;
44+
switch_body = [S.return_stmt (E.str r)],
4545
false (* FIXME: if true, still print break*)
4646
}) dispatches))]
4747

@@ -58,8 +58,8 @@ let eval_as_event (arg : J.expression) (dispatches : (int * string) list ) =
5858
(E.of_block
5959
[(S.int_switch (E.index arg 0l)
6060
(Ext_list.map (fun (i,r) ->
61-
{J.case = i ;
62-
body = [S.return_stmt (E.str r)],
61+
{J.switch_case = i ;
62+
switch_body = [S.return_stmt (E.str r)],
6363
false (* FIXME: if true, still print break*)
6464
}) dispatches))]
6565
, (* TODO: improve, one dispatch later,
@@ -86,8 +86,8 @@ let eval_as_int (arg : J.expression) (dispatches : (int * int) list ) : E.t =
8686
E.of_block
8787
[(S.int_switch arg
8888
(Ext_list.map (fun (i,r) ->
89-
{J.case = i ;
90-
body = [S.return_stmt (E.int (Int32.of_int r))],
89+
{J.switch_case = i ;
90+
switch_body = [S.return_stmt (E.int (Int32.of_int r))],
9191
false (* FIXME: if true, still print break*)
9292
}) dispatches))]
9393

Diff for: jscomp/core/js_output.ml

+2-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ let to_break_block (x : t) : J.block * bool =
122122
TODO: check if it has side efects
123123
*)
124124
| { value = None; finished } ->
125-
block, (match finished with | True -> false | (False | Dummy) -> true )
125+
block,
126+
(match finished with | True -> false | (False | Dummy) -> true )
126127

127128
| {value = Some _ as opt; _} ->
128129
block_with_opt_expr block opt, true

Diff for: jscomp/core/js_stmt_make.ml

+4-3
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ let int_switch ?comment ?declaration ?default (e : J.expression) clauses : t
100100
let continuation =
101101
begin match Ext_list.find_opt
102102
(fun (x : _ J.case_clause) ->
103-
if x.case = (Int32.to_int i) then Some (fst x.body) else None ) clauses
103+
if x.switch_case = (Int32.to_int i) then
104+
Some (fst x.switch_body) else None ) clauses
104105
with
105106
| Some case -> case
106107
| None ->
@@ -137,8 +138,8 @@ let string_switch ?comment ?declaration ?default (e : J.expression) clauses :
137138
let continuation =
138139
begin match Ext_list.find_opt
139140
(fun (x : string J.case_clause) ->
140-
if x.case = s then
141-
Some (fst x.body)
141+
if x.switch_case = s then
142+
Some (fst x.switch_body)
142143
else None
143144
) clauses
144145
with

Diff for: jscomp/core/lam_compile.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,10 @@ and compile_general_cases :
480480
|> Ext_list.map_last
481481
(fun last (x,lam) ->
482482
if last
483-
then {J.case = x;
484-
body =
483+
then {J.switch_case = x;
484+
switch_body =
485485
Js_output.to_break_block (compile_lambda cxt lam) }
486-
else { case = x; body = [],false }))
486+
else { switch_case = x; switch_body = [],false }))
487487
(* TODO: we should also group default *)
488488
(* The last clause does not need [break]
489489
common break through, *)

Diff for: jscomp/others/.depend

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ belt_MapString.cmj : belt_internalMapString.cmj belt_internalAVLtree.cmj \
5757
belt_Array.cmj belt_MapString.cmi
5858
belt_MapInt.cmj : belt_internalMapInt.cmj belt_internalAVLtree.cmj \
5959
belt_Array.cmj belt_MapInt.cmi
60+
belt_Option.cmj : belt_Option.cmi
6061
belt_Set.cmj : belt_SetString.cmj belt_SetInt.cmj belt_SetDict.cmj \
6162
belt_Id.cmj belt_Array.cmj belt_Set.cmi
6263
belt_MutableSet.cmj : belt_internalAVLset.cmj belt_SortArray.cmj \
@@ -127,6 +128,7 @@ belt_Map.cmi : belt_MapString.cmi belt_MapInt.cmi belt_MapDict.cmi \
127128
belt_Id.cmi
128129
belt_MapString.cmi :
129130
belt_MapInt.cmi :
131+
belt_Option.cmi :
130132
belt_Set.cmi : belt_SetString.cmi belt_SetInt.cmi belt_SetDict.cmi \
131133
belt_Id.cmi
132134
belt_MutableSet.cmi : belt_MutableSetString.cmi belt_MutableSetInt.cmi \

Diff for: jscomp/test/.depend

+1
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ gpr_1946_test.cmj : ../stdlib/obj.cmj ../runtime/js.cmj
302302
gpr_2250_test.cmj : mt.cmj
303303
gpr_2316_test.cmj : mt.cmj ../runtime/js.cmj
304304
gpr_2352_test.cmj :
305+
gpr_2413_test.cmj :
305306
gpr_2474.cmj :
306307
gpr_2487.cmj : ../others/belt.cmj
307308
gpr_2503_test.cmj : mt.cmj ../runtime/js.cmj

Diff for: jscomp/test/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ OTHERS := test_literals a test_ari test_export2 test_internalOO test_obj_simple_
245245
pipe_syntax\
246246
gpr_2352_test\
247247
gpr_2633_test\
248+
gpr_2413_test\
248249
# bs_uncurry_test
249250
# needs Lam to get rid of Uncurry arity first
250251
# simple_derive_test

Diff for: jscomp/test/gpr_2413_test.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict';
2+
3+
var Caml_int32 = require("../../lib/js/caml_int32.js");
4+
5+
function f(param) {
6+
var exit = 0;
7+
switch (param.tag | 0) {
8+
case 0 :
9+
var match = param[0];
10+
if (match.tag) {
11+
var a = match[0];
12+
return a - a | 0;
13+
} else {
14+
var a$1 = match[0];
15+
return a$1 + a$1 | 0;
16+
}
17+
break;
18+
case 1 :
19+
case 2 :
20+
exit = 1;
21+
break;
22+
23+
}
24+
if (exit === 1) {
25+
var a$2 = param[0][0];
26+
return Caml_int32.imul(a$2, a$2);
27+
}
28+
29+
}
30+
31+
exports.f = f;
32+
/* No side effect */

Diff for: jscomp/test/gpr_2413_test.ml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
type inner =
2+
| P of int
3+
| S of int
4+
5+
type outer =
6+
| A of inner
7+
| B of inner
8+
| C of inner
9+
10+
let f = function
11+
(* These cause unreachable code *)
12+
| A P a -> a + a
13+
| A S a -> a - a
14+
(* These don't, because there's commonality between them *)
15+
| B P a | B S a | C P a | C S a -> a * a

Diff for: lib/whole_compiler.d

+1
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@
492492
../lib/whole_compiler.ml : ./syntax/ast_tuple_pattern_flatten.mli
493493
../lib/whole_compiler.ml : ./core/js_pass_flatten_and_mark_dead.ml
494494
../lib/whole_compiler.ml : ./outcome_printer/outcome_printer_ns.ml
495+
../lib/whole_compiler.ml : ./outcome_printer/reason_syntax_util.ml
495496
../lib/whole_compiler.ml : ./core/js_pass_flatten_and_mark_dead.mli
496497
../lib/whole_compiler.ml : ./outcome_printer/outcome_printer_ns.mli
497498
../lib/whole_compiler.ml : ./outcome_printer/tweaked_reason_oprint.ml

0 commit comments

Comments
 (0)