Skip to content

Commit 5971b6a

Browse files
committed
[tweak] refine eq_approx
1 parent 054177e commit 5971b6a

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

jscomp/core/lam.ml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,14 @@ let rec
400400
Lam_primitive.eq_primitive_approx info1.primitive info2.primitive &&
401401
eq_approx_list info1.args info2.args
402402
| _ -> false)
403-
| Lstringswitch _ -> false
403+
| Lstringswitch (arg, patterns, default) ->
404+
begin match l2 with
405+
|Lstringswitch(arg2,patterns2, default2) ->
406+
eq_approx arg arg2 &&
407+
eq_option default default2 &&
408+
Ext_list.for_all2_no_exn patterns patterns2 (fun ((k:string),v) (k2,v2) -> k = k2 && eq_approx v v2)
409+
| _ -> false
410+
end
404411
| Lfunction _
405412
| Llet (_,_,_,_)
406413
| Lletrec _
@@ -410,7 +417,10 @@ let rec
410417
| Lfor (_,_,_,_,_)
411418
| Lsend _
412419
-> false
413-
420+
and eq_option l1 l2 =
421+
match l1 with
422+
| None -> l2 = None
423+
| Some l1 -> (match l2 with Some l2 -> eq_approx l1 l2 | None -> false)
414424
and eq_approx_list ls ls1 = Ext_list.for_all2_no_exn ls ls1 eq_approx
415425

416426

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96369,7 +96369,14 @@ let rec
9636996369
Lam_primitive.eq_primitive_approx info1.primitive info2.primitive &&
9637096370
eq_approx_list info1.args info2.args
9637196371
| _ -> false)
96372-
| Lstringswitch _ -> false
96372+
| Lstringswitch (arg, patterns, default) ->
96373+
begin match l2 with
96374+
|Lstringswitch(arg2,patterns2, default2) ->
96375+
eq_approx arg arg2 &&
96376+
eq_option default default2 &&
96377+
Ext_list.for_all2_no_exn patterns patterns2 (fun ((k:string),v) (k2,v2) -> k = k2 && eq_approx v v2)
96378+
| _ -> false
96379+
end
9637396380
| Lfunction _
9637496381
| Llet (_,_,_,_)
9637596382
| Lletrec _
@@ -96379,7 +96386,10 @@ let rec
9637996386
| Lfor (_,_,_,_,_)
9638096387
| Lsend _
9638196388
-> false
96382-
96389+
and eq_option l1 l2 =
96390+
match l1 with
96391+
| None -> l2 = None
96392+
| Some l1 -> (match l2 with Some l2 -> eq_approx l1 l2 | None -> false)
9638396393
and eq_approx_list ls ls1 = Ext_list.for_all2_no_exn ls ls1 eq_approx
9638496394

9638596395

lib/4.06.1/whole_compiler.ml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371865,7 +371865,14 @@ let rec
371865371865
Lam_primitive.eq_primitive_approx info1.primitive info2.primitive &&
371866371866
eq_approx_list info1.args info2.args
371867371867
| _ -> false)
371868-
| Lstringswitch _ -> false
371868+
| Lstringswitch (arg, patterns, default) ->
371869+
begin match l2 with
371870+
|Lstringswitch(arg2,patterns2, default2) ->
371871+
eq_approx arg arg2 &&
371872+
eq_option default default2 &&
371873+
Ext_list.for_all2_no_exn patterns patterns2 (fun ((k:string),v) (k2,v2) -> k = k2 && eq_approx v v2)
371874+
| _ -> false
371875+
end
371869371876
| Lfunction _
371870371877
| Llet (_,_,_,_)
371871371878
| Lletrec _
@@ -371875,7 +371882,10 @@ let rec
371875371882
| Lfor (_,_,_,_,_)
371876371883
| Lsend _
371877371884
-> false
371878-
371885+
and eq_option l1 l2 =
371886+
match l1 with
371887+
| None -> l2 = None
371888+
| Some l1 -> (match l2 with Some l2 -> eq_approx l1 l2 | None -> false)
371879371889
and eq_approx_list ls ls1 = Ext_list.for_all2_no_exn ls ls1 eq_approx
371880371890

371881371891

0 commit comments

Comments
 (0)