Skip to content

Commit 6913da9

Browse files
committed
Bring ad-hoc simplification of && generation up to speed.
1 parent fc6f9e9 commit 6913da9

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

compiler/core/js_exp_make.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,14 @@ let rec filter_bool (e : t) ~j ~b =
673673
match (filter_bool e1 ~j ~b, filter_bool e2 ~j ~b) with
674674
| None, _ | _, None -> None
675675
| Some e1, Some e2 -> Some {e with expression_desc = Bin (Or, e1, e2)})
676+
| Bin (EqEqEq, {expression_desc = Var i}, {expression_desc = Bool b1})
677+
| Bin (EqEqEq, {expression_desc = Bool b1}, {expression_desc = Var i})
678+
when Js_op_util.same_vident i j ->
679+
if b1 = b then None else Some e
680+
| Bin (NotEqEq, {expression_desc = Var i}, {expression_desc = Bool b1})
681+
| Bin (NotEqEq, {expression_desc = Bool b1}, {expression_desc = Var i})
682+
when Js_op_util.same_vident i j ->
683+
if b1 <> b then None else Some e
676684
| Bin
677685
( NotEqEq,
678686
{expression_desc = Typeof {expression_desc = Var i}},

tests/tests/src/UntaggedVariants.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,9 @@ function check$1(s) {
386386
return;
387387
}
388388
let match = s[0];
389-
if ((match === null || match === true || match === false || match === undefined) && match === true) {
389+
if (match === true) {
390390
let match$1 = s[1];
391-
if ((match$1 === null || match$1 === true || match$1 === false || match$1 === undefined) && match$1 === false) {
391+
if (match$1 === false) {
392392
let match$2 = s[2];
393393
if (match$2 === null || match$2 === true || match$2 === false || match$2 === undefined) {
394394
console.log("Nope...");

0 commit comments

Comments
 (0)