Skip to content

Commit b59b105

Browse files
authored
Merge pull request #4858 from rescript-lang/compiler_changes
fix #4856, more comments around pattern match compilation
2 parents 5cc4292 + 16e52ff commit b59b105

Some content is hidden

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

46 files changed

+3723
-3742
lines changed

jscomp/core/js_exp_make.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -799,16 +799,16 @@ let rec float_equal ?comment (e0 : t) (e1 : t) : t =
799799
| Number (Int {i = i0 ; _}), Number (Int {i = i1; }) ->
800800
bool (i0 = i1)
801801
| Undefined , Undefined -> true_
802-
| (Bin(Bor,
802+
(* | (Bin(Bor,
803803
{expression_desc = Number(Int {i = 0l; _})},
804804
({expression_desc = Caml_block_tag _; _} as a ))
805805
|
806806
Bin(Bor,
807807
({expression_desc = Caml_block_tag _; _} as a),
808808
{expression_desc = Number (Int {i = 0l; _})})),
809-
Number (Int {i = 0l; _})
809+
Number (Int {i = 0l;}) when e1.comment = None
810810
-> (** (x.tag | 0) === 0 *)
811-
not a
811+
not a *)
812812
| (Bin(Bor,
813813
{expression_desc = Number(Int {i = 0l; _})},
814814
({expression_desc = Caml_block_tag _; _} as a ))

jscomp/core/lam_print.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,12 @@ let lambda ppf v =
383383
List.iter
384384
(fun (n, l) ->
385385
if !spc then fprintf ppf "@ " else spc := true;
386-
fprintf ppf "@[<hv 1>case int %i:@ %a@]" n lam l)
386+
fprintf ppf "@[<hv 1>case int %i %S:@ %a@]" n (match sw.sw_names with None -> "" | Some x -> x.consts.(n)) lam l)
387387
sw.sw_consts;
388388
List.iter
389389
(fun (n, l) ->
390390
if !spc then fprintf ppf "@ " else spc := true;
391-
fprintf ppf "@[<hv 1>case tag %i:@ %a@]" n lam l)
391+
fprintf ppf "@[<hv 1>case tag %i %S:@ %a@]" n (match sw.sw_names with None -> "" | Some x -> x.blocks.(n)) lam l)
392392
sw.sw_blocks ;
393393
begin match sw.sw_failaction with
394394
| None -> ()

jscomp/test/adt_optimize_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function f11(x) {
153153
if (typeof x === "number") {
154154
return 2;
155155
}
156-
if (!x.TAG) {
156+
if (x.TAG === /* D */0) {
157157
return 1;
158158
}
159159
throw {

0 commit comments

Comments
 (0)