diff --git a/CHANGELOG.md b/CHANGELOG.md index afe24e625b..12fbd58f77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Editor: Fix issue where pipe completions would not trigger with generic type arguments. https://github.com/rescript-lang/rescript/pull/7231 - Fix leftover assert false in code for `null != undefined`. https://github.com/rescript-lang/rescript/pull/7232 - Editor: Fix issue where completions would not show up inside of object bodies. https://github.com/rescript-lang/rescript/pull/7230 +- Fix issue with pattern matching empty list which interferes with boolean optimisations. https://github.com/rescript-lang/rescript/pull/7237 #### :house: Internal diff --git a/compiler/ml/matching.ml b/compiler/ml/matching.ml index 2cd1a25db0..03161b8c53 100644 --- a/compiler/ml/matching.ml +++ b/compiler/ml/matching.ml @@ -2245,7 +2245,8 @@ let combine_constructor sw_names loc arg ex_pat cstr partial ctx def let arg = if Datarepr.constructor_has_optional_shape cstr then Lprim (Pis_not_none, [arg], loc) - else arg + else + Lprim (Pjscomp Cneq, [arg; Lconst (Const_base (Const_int 0))], loc) in Lifthenelse (arg, act2, act1) | 2, 0, [(i1, act1); (_, act2)], [] diff --git a/lib/es6/Belt_List.js b/lib/es6/Belt_List.js index 22455cc2e0..f7cf86aa06 100644 --- a/lib/es6/Belt_List.js +++ b/lib/es6/Belt_List.js @@ -5,14 +5,14 @@ import * as Belt_SortArray from "./Belt_SortArray.js"; import * as Primitive_option from "./Primitive_option.js"; function head(x) { - if (x) { + if (x !== 0) { return Primitive_option.some(x.hd); } } function headExn(x) { - if (x) { + if (x !== 0) { return x.hd; } throw { @@ -22,14 +22,14 @@ function headExn(x) { } function tail(x) { - if (x) { + if (x !== 0) { return x.tl; } } function tailExn(x) { - if (x) { + if (x !== 0) { return x.tl; } throw { @@ -54,7 +54,7 @@ function get(x, n) { while (true) { let n$1 = _n; let x$1 = _x; - if (!x$1) { + if (x$1 === 0) { return; } if (n$1 === 0) { @@ -79,7 +79,7 @@ function getExn(x, n) { while (true) { let n$1 = _n; let x$1 = _x; - if (x$1) { + if (x$1 !== 0) { if (n$1 === 0) { return x$1.hd; } @@ -99,7 +99,7 @@ function partitionAux(p, _cell, _precX, _precY) { let precY = _precY; let precX = _precX; let cell = _cell; - if (!cell) { + if (cell === 0) { return; } let t = cell.tl; @@ -126,7 +126,7 @@ function splitAux(_cell, _precX, _precY) { let precY = _precY; let precX = _precX; let cell = _cell; - if (!cell) { + if (cell === 0) { return; } let match = cell.hd; @@ -151,7 +151,7 @@ function copyAuxCont(_cellX, _prec) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return prec; } let next = { @@ -169,7 +169,7 @@ function copyAuxWitFilter(f, _cellX, _prec) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } let t = cellX.tl; @@ -194,7 +194,7 @@ function copyAuxWithFilterIndex(f, _cellX, _prec, _i) { let i = _i; let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } let t = cellX.tl; @@ -220,7 +220,7 @@ function copyAuxWitFilterMap(f, _cellX, _prec) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } let t = cellX.tl; @@ -244,7 +244,7 @@ function removeAssocAuxWithMap(_cellX, x, _prec, f) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return false; } let t = cellX.tl; @@ -268,7 +268,7 @@ function setAssocAuxWithMap(_cellX, x, k, _prec, eq) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return false; } let t = cellX.tl; @@ -298,7 +298,7 @@ function copyAuxWithMap(_cellX, _prec, f) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } let next = { @@ -317,10 +317,10 @@ function zipAux(_cellX, _cellY, _prec) { let prec = _prec; let cellY = _cellY; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } - if (!cellY) { + if (cellY === 0) { return; } let next = { @@ -343,10 +343,10 @@ function copyAuxWithMap2(f, _cellX, _cellY, _prec) { let prec = _prec; let cellY = _cellY; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } - if (!cellY) { + if (cellY === 0) { return; } let next = { @@ -366,7 +366,7 @@ function copyAuxWithMapI(f, _i, _cellX, _prec) { let prec = _prec; let cellX = _cellX; let i = _i; - if (!cellX) { + if (cellX === 0) { return; } let next = { @@ -389,7 +389,7 @@ function takeAux(_n, _cell, _prec) { if (n === 0) { return true; } - if (!cell) { + if (cell === 0) { return false; } let cell$1 = { @@ -412,7 +412,7 @@ function splitAtAux(_n, _cell, _prec) { if (n === 0) { return cell; } - if (!cell) { + if (cell === 0) { return; } let cell$1 = { @@ -434,7 +434,7 @@ function take(lst, n) { if (n === 0) { return /* [] */0; } - if (!lst) { + if (lst === 0) { return; } let cell = { @@ -460,7 +460,7 @@ function drop(lst, n) { if (n$1 === 0) { return l; } - if (!l) { + if (l === 0) { return; } _n = n$1 - 1 | 0; @@ -480,7 +480,7 @@ function splitAt(lst, n) { lst ]; } - if (!lst) { + if (lst === 0) { return; } let cell = { @@ -498,7 +498,7 @@ function splitAt(lst, n) { } function concat(xs, ys) { - if (!xs) { + if (xs === 0) { return ys; } let cell = { @@ -510,7 +510,7 @@ function concat(xs, ys) { } function map(xs, f) { - if (!xs) { + if (xs === 0) { return /* [] */0; } let cell = { @@ -522,10 +522,10 @@ function map(xs, f) { } function zipBy(l1, l2, f) { - if (!l1) { + if (l1 === 0) { return /* [] */0; } - if (!l2) { + if (l2 === 0) { return /* [] */0; } let cell = { @@ -537,7 +537,7 @@ function zipBy(l1, l2, f) { } function mapWithIndex(xs, f) { - if (!xs) { + if (xs === 0) { return /* [] */0; } let cell = { @@ -598,7 +598,7 @@ function length(xs) { while (true) { let acc = _acc; let x = _x; - if (!x) { + if (x === 0) { return acc; } _acc = acc + 1 | 0; @@ -611,7 +611,7 @@ function fillAux(arr, _i, _x) { while (true) { let x = _x; let i = _i; - if (!x) { + if (x === 0) { return; } arr[i] = x.hd; @@ -656,7 +656,7 @@ function reverseConcat(_l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return l2; } _l2 = { @@ -676,7 +676,7 @@ function flattenAux(_prec, _xs) { while (true) { let xs = _xs; let prec = _prec; - if (xs) { + if (xs !== 0) { _xs = xs.tl; _prec = copyAuxCont(xs.hd, prec); continue; @@ -689,11 +689,11 @@ function flattenAux(_prec, _xs) { function flatten(_xs) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return /* [] */0; } let match = xs.hd; - if (match) { + if (match !== 0) { let cell = { hd: match.hd, tl: /* [] */0 @@ -728,7 +728,7 @@ function mapReverse(l, f) { while (true) { let xs = _xs; let accu = _accu; - if (!xs) { + if (xs === 0) { return accu; } _xs = xs.tl; @@ -743,7 +743,7 @@ function mapReverse(l, f) { function forEach(_xs, f) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return; } f(xs.hd); @@ -758,7 +758,7 @@ function forEachWithIndex(l, f) { while (true) { let i = _i; let xs = _xs; - if (!xs) { + if (xs === 0) { return; } f(i, xs.hd); @@ -772,7 +772,7 @@ function reduce(_l, _accu, f) { while (true) { let accu = _accu; let l = _l; - if (!l) { + if (l === 0) { return accu; } _accu = f(accu, l.hd); @@ -782,7 +782,7 @@ function reduce(_l, _accu, f) { } function reduceReverseUnsafe(l, accu, f) { - if (l) { + if (l !== 0) { return f(reduceReverseUnsafe(l.tl, accu, f), l.hd); } else { return accu; @@ -806,7 +806,7 @@ function reduceWithIndex(l, acc, f) { let i = _i; let acc$1 = _acc; let l$1 = _l; - if (!l$1) { + if (l$1 === 0) { return acc$1; } _i = i + 1 | 0; @@ -824,10 +824,10 @@ function mapReverse2(l1, l2, f) { let accu = _accu; let l2$1 = _l2; let l1$1 = _l1; - if (!l1$1) { + if (l1$1 === 0) { return accu; } - if (!l2$1) { + if (l2$1 === 0) { return accu; } _accu = { @@ -844,10 +844,10 @@ function forEach2(_l1, _l2, f) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return; } - if (!l2) { + if (l2 === 0) { return; } f(l1.hd, l2.hd); @@ -862,10 +862,10 @@ function reduce2(_l1, _l2, _accu, f) { let accu = _accu; let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return accu; } - if (!l2) { + if (l2 === 0) { return accu; } _accu = f(accu, l1.hd, l2.hd); @@ -876,7 +876,7 @@ function reduce2(_l1, _l2, _accu, f) { } function reduceReverse2Unsafe(l1, l2, accu, f) { - if (l1 && l2) { + if (l1 !== 0 && l2 !== 0) { return f(reduceReverse2Unsafe(l1.tl, l2.tl, accu, f), l1.hd, l2.hd); } else { return accu; @@ -895,7 +895,7 @@ function reduceReverse2(l1, l2, acc, f) { function every(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return true; } if (!p(xs.hd)) { @@ -909,7 +909,7 @@ function every(_xs, p) { function some(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return false; } if (p(xs.hd)) { @@ -924,10 +924,10 @@ function every2(_l1, _l2, p) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return true; } - if (!l2) { + if (l2 === 0) { return true; } if (!p(l1.hd, l2.hd)) { @@ -943,14 +943,14 @@ function cmpByLength(_l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { - if (l2) { + if (l1 === 0) { + if (l2 !== 0) { return -1; } else { return 0; } } - if (!l2) { + if (l2 === 0) { return 1; } _l2 = l2.tl; @@ -963,14 +963,14 @@ function cmp(_l1, _l2, p) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { - if (l2) { + if (l1 === 0) { + if (l2 !== 0) { return -1; } else { return 0; } } - if (!l2) { + if (l2 === 0) { return 1; } let c = p(l1.hd, l2.hd); @@ -987,10 +987,10 @@ function eq(_l1, _l2, p) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { - return !l2; + if (l1 === 0) { + return l2 === 0; } - if (!l2) { + if (l2 === 0) { return false; } if (!p(l1.hd, l2.hd)) { @@ -1006,10 +1006,10 @@ function some2(_l1, _l2, p) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return false; } - if (!l2) { + if (l2 === 0) { return false; } if (p(l1.hd, l2.hd)) { @@ -1024,7 +1024,7 @@ function some2(_l1, _l2, p) { function has(_xs, x, eq) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return false; } if (eq(xs.hd, x)) { @@ -1038,7 +1038,7 @@ function has(_xs, x, eq) { function getAssoc(_xs, x, eq) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return; } let match = xs.hd; @@ -1053,7 +1053,7 @@ function getAssoc(_xs, x, eq) { function hasAssoc(_xs, x, eq) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return false; } if (eq(xs.hd[0], x)) { @@ -1065,7 +1065,7 @@ function hasAssoc(_xs, x, eq) { } function removeAssoc(xs, x, eq) { - if (!xs) { + if (xs === 0) { return /* [] */0; } let l = xs.tl; @@ -1086,7 +1086,7 @@ function removeAssoc(xs, x, eq) { } function setAssoc(xs, x, k, eq) { - if (!xs) { + if (xs === 0) { return { hd: [ x, @@ -1133,7 +1133,7 @@ function sort(xs, cmp) { function getBy(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return; } let x = xs.hd; @@ -1148,7 +1148,7 @@ function getBy(_xs, p) { function keep(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return /* [] */0; } let t = xs.tl; @@ -1172,7 +1172,7 @@ function keepWithIndex(xs, p) { while (true) { let i = _i; let xs$1 = _xs; - if (!xs$1) { + if (xs$1 === 0) { return /* [] */0; } let t = xs$1.tl; @@ -1194,7 +1194,7 @@ function keepWithIndex(xs, p) { function keepMap(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return /* [] */0; } let t = xs.tl; @@ -1213,7 +1213,7 @@ function keepMap(_xs, p) { } function partition(l, p) { - if (!l) { + if (l === 0) { return [ /* [] */0, /* [] */0 @@ -1244,7 +1244,7 @@ function partition(l, p) { } function unzip(xs) { - if (!xs) { + if (xs === 0) { return [ /* [] */0, /* [] */0 @@ -1267,10 +1267,10 @@ function unzip(xs) { } function zip(l1, l2) { - if (!l1) { + if (l1 === 0) { return /* [] */0; } - if (!l2) { + if (l2 === 0) { return /* [] */0; } let cell = { diff --git a/lib/es6/Belt_internalAVLset.js b/lib/es6/Belt_internalAVLset.js index bcc1ca58f8..c96f412eb4 100644 --- a/lib/es6/Belt_internalAVLset.js +++ b/lib/es6/Belt_internalAVLset.js @@ -589,10 +589,10 @@ function cmp(s1, s2, cmp$1) { while (true) { let e2 = _e2; let e1 = _e1; - if (!e1) { + if (e1 === 0) { return 0; } - if (!e2) { + if (e2 === 0) { return 0; } let h2 = e2.hd; diff --git a/lib/es6/Belt_internalAVLtree.js b/lib/es6/Belt_internalAVLtree.js index c5454dafda..0745420221 100644 --- a/lib/es6/Belt_internalAVLtree.js +++ b/lib/es6/Belt_internalAVLtree.js @@ -749,10 +749,10 @@ function cmp(s1, s2, kcmp, vcmp) { while (true) { let e2 = _e2; let e1 = _e1; - if (!e1) { + if (e1 === 0) { return 0; } - if (!e2) { + if (e2 === 0) { return 0; } let h2 = e2.hd; @@ -785,10 +785,10 @@ function eq(s1, s2, kcmp, veq) { while (true) { let e2 = _e2; let e1 = _e1; - if (!e1) { + if (e1 === 0) { return true; } - if (!e2) { + if (e2 === 0) { return true; } let h2 = e2.hd; diff --git a/lib/es6/Belt_internalMapInt.js b/lib/es6/Belt_internalMapInt.js index 698255f843..292662c21a 100644 --- a/lib/es6/Belt_internalMapInt.js +++ b/lib/es6/Belt_internalMapInt.js @@ -211,10 +211,10 @@ function compareAux(_e1, _e2, vcmp) { while (true) { let e2 = _e2; let e1 = _e1; - if (!e1) { + if (e1 === 0) { return 0; } - if (!e2) { + if (e2 === 0) { return 0; } let h2 = e2.hd; @@ -249,10 +249,10 @@ function eqAux(_e1, _e2, eq) { while (true) { let e2 = _e2; let e1 = _e1; - if (!e1) { + if (e1 === 0) { return true; } - if (!e2) { + if (e2 === 0) { return true; } let h2 = e2.hd; diff --git a/lib/es6/Belt_internalMapString.js b/lib/es6/Belt_internalMapString.js index 9083d62782..a156d6bc44 100644 --- a/lib/es6/Belt_internalMapString.js +++ b/lib/es6/Belt_internalMapString.js @@ -211,10 +211,10 @@ function compareAux(_e1, _e2, vcmp) { while (true) { let e2 = _e2; let e1 = _e1; - if (!e1) { + if (e1 === 0) { return 0; } - if (!e2) { + if (e2 === 0) { return 0; } let h2 = e2.hd; @@ -249,10 +249,10 @@ function eqAux(_e1, _e2, eq) { while (true) { let e2 = _e2; let e1 = _e1; - if (!e1) { + if (e1 === 0) { return true; } - if (!e2) { + if (e2 === 0) { return true; } let h2 = e2.hd; diff --git a/lib/es6/Belt_internalSetInt.js b/lib/es6/Belt_internalSetInt.js index d3cf1d8a5e..53d46e6d7e 100644 --- a/lib/es6/Belt_internalSetInt.js +++ b/lib/es6/Belt_internalSetInt.js @@ -22,10 +22,10 @@ function compareAux(_e1, _e2) { while (true) { let e2 = _e2; let e1 = _e1; - if (!e1) { + if (e1 === 0) { return 0; } - if (!e2) { + if (e2 === 0) { return 0; } let h2 = e2.hd; diff --git a/lib/es6/Belt_internalSetString.js b/lib/es6/Belt_internalSetString.js index 0fa49af7c1..75c0c3e8da 100644 --- a/lib/es6/Belt_internalSetString.js +++ b/lib/es6/Belt_internalSetString.js @@ -22,10 +22,10 @@ function compareAux(_e1, _e2) { while (true) { let e2 = _e2; let e1 = _e1; - if (!e1) { + if (e1 === 0) { return 0; } - if (!e2) { + if (e2 === 0) { return 0; } let h2 = e2.hd; diff --git a/lib/es6/Js_dict.js b/lib/es6/Js_dict.js index 4c1c6bcd65..3e56207162 100644 --- a/lib/es6/Js_dict.js +++ b/lib/es6/Js_dict.js @@ -42,7 +42,7 @@ function fromList(entries) { let _x = entries; while (true) { let x = _x; - if (!x) { + if (x === 0) { return dict; } let match = x.hd; diff --git a/lib/es6/List.js b/lib/es6/List.js index 06760467a5..2b0f6cd7d2 100644 --- a/lib/es6/List.js +++ b/lib/es6/List.js @@ -5,14 +5,14 @@ import * as Primitive_int from "./Primitive_int.js"; import * as Primitive_option from "./Primitive_option.js"; function head(x) { - if (x) { + if (x !== 0) { return Primitive_option.some(x.hd); } } function headExn(x) { - if (x) { + if (x !== 0) { return x.hd; } throw { @@ -22,14 +22,14 @@ function headExn(x) { } function tail(x) { - if (x) { + if (x !== 0) { return x.tl; } } function tailExn(x) { - if (x) { + if (x !== 0) { return x.tl; } throw { @@ -54,7 +54,7 @@ function get(x, n) { while (true) { let n$1 = _n; let x$1 = _x; - if (!x$1) { + if (x$1 === 0) { return; } if (n$1 === 0) { @@ -79,7 +79,7 @@ function getExn(x, n) { while (true) { let n$1 = _n; let x$1 = _x; - if (x$1) { + if (x$1 !== 0) { if (n$1 === 0) { return x$1.hd; } @@ -99,7 +99,7 @@ function partitionAux(p, _cell, _precX, _precY) { let precY = _precY; let precX = _precX; let cell = _cell; - if (!cell) { + if (cell === 0) { return; } let t = cell.tl; @@ -126,7 +126,7 @@ function splitAux(_cell, _precX, _precY) { let precY = _precY; let precX = _precX; let cell = _cell; - if (!cell) { + if (cell === 0) { return; } let match = cell.hd; @@ -151,7 +151,7 @@ function copyAuxCont(_cellX, _prec) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return prec; } let next = { @@ -169,7 +169,7 @@ function copyAuxWitFilter(f, _cellX, _prec) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } let t = cellX.tl; @@ -194,7 +194,7 @@ function copyAuxWithFilterIndex(f, _cellX, _prec, _i) { let i = _i; let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } let t = cellX.tl; @@ -220,7 +220,7 @@ function copyAuxWitFilterMap(f, _cellX, _prec) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } let t = cellX.tl; @@ -244,7 +244,7 @@ function removeAssocAuxWithMap(_cellX, x, _prec, f) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return false; } let t = cellX.tl; @@ -268,7 +268,7 @@ function setAssocAuxWithMap(_cellX, x, k, _prec, eq) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return false; } let t = cellX.tl; @@ -298,7 +298,7 @@ function copyAuxWithMap(_cellX, _prec, f) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } let next = { @@ -317,10 +317,10 @@ function zipAux(_cellX, _cellY, _prec) { let prec = _prec; let cellY = _cellY; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } - if (!cellY) { + if (cellY === 0) { return; } let next = { @@ -343,10 +343,10 @@ function copyAuxWithMap2(f, _cellX, _cellY, _prec) { let prec = _prec; let cellY = _cellY; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } - if (!cellY) { + if (cellY === 0) { return; } let next = { @@ -366,7 +366,7 @@ function copyAuxWithMapI(f, _i, _cellX, _prec) { let prec = _prec; let cellX = _cellX; let i = _i; - if (!cellX) { + if (cellX === 0) { return; } let next = { @@ -389,7 +389,7 @@ function takeAux(_n, _cell, _prec) { if (n === 0) { return true; } - if (!cell) { + if (cell === 0) { return false; } let cell$1 = { @@ -412,7 +412,7 @@ function splitAtAux(_n, _cell, _prec) { if (n === 0) { return cell; } - if (!cell) { + if (cell === 0) { return; } let cell$1 = { @@ -434,7 +434,7 @@ function take(lst, n) { if (n === 0) { return /* [] */0; } - if (!lst) { + if (lst === 0) { return; } let cell = { @@ -460,7 +460,7 @@ function drop(lst, n) { if (n$1 === 0) { return l; } - if (!l) { + if (l === 0) { return; } _n = n$1 - 1 | 0; @@ -480,7 +480,7 @@ function splitAt(lst, n) { lst ]; } - if (!lst) { + if (lst === 0) { return; } let cell = { @@ -498,7 +498,7 @@ function splitAt(lst, n) { } function concat(xs, ys) { - if (!xs) { + if (xs === 0) { return ys; } let cell = { @@ -510,7 +510,7 @@ function concat(xs, ys) { } function map(xs, f) { - if (!xs) { + if (xs === 0) { return /* [] */0; } let cell = { @@ -522,10 +522,10 @@ function map(xs, f) { } function zipBy(l1, l2, f) { - if (!l1) { + if (l1 === 0) { return /* [] */0; } - if (!l2) { + if (l2 === 0) { return /* [] */0; } let cell = { @@ -537,7 +537,7 @@ function zipBy(l1, l2, f) { } function mapWithIndex(xs, f) { - if (!xs) { + if (xs === 0) { return /* [] */0; } let cell = { @@ -598,7 +598,7 @@ function length(xs) { while (true) { let acc = _acc; let x = _x; - if (!x) { + if (x === 0) { return acc; } _acc = acc + 1 | 0; @@ -611,7 +611,7 @@ function fillAux(arr, _i, _x) { while (true) { let x = _x; let i = _i; - if (!x) { + if (x === 0) { return; } arr[i] = x.hd; @@ -656,7 +656,7 @@ function reverseConcat(_l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return l2; } _l2 = { @@ -676,7 +676,7 @@ function flatAux(_prec, _xs) { while (true) { let xs = _xs; let prec = _prec; - if (xs) { + if (xs !== 0) { _xs = xs.tl; _prec = copyAuxCont(xs.hd, prec); continue; @@ -689,11 +689,11 @@ function flatAux(_prec, _xs) { function flat(_xs) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return /* [] */0; } let match = xs.hd; - if (match) { + if (match !== 0) { let cell = { hd: match.hd, tl: /* [] */0 @@ -728,7 +728,7 @@ function mapReverse(l, f) { while (true) { let xs = _xs; let accu = _accu; - if (!xs) { + if (xs === 0) { return accu; } _xs = xs.tl; @@ -743,7 +743,7 @@ function mapReverse(l, f) { function forEach(_xs, f) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return; } f(xs.hd); @@ -758,7 +758,7 @@ function forEachWithIndex(l, f) { while (true) { let i = _i; let xs = _xs; - if (!xs) { + if (xs === 0) { return; } f(xs.hd, i); @@ -772,7 +772,7 @@ function reduce(_l, _accu, f) { while (true) { let accu = _accu; let l = _l; - if (!l) { + if (l === 0) { return accu; } _accu = f(accu, l.hd); @@ -782,7 +782,7 @@ function reduce(_l, _accu, f) { } function reduceReverseUnsafe(l, accu, f) { - if (l) { + if (l !== 0) { return f(reduceReverseUnsafe(l.tl, accu, f), l.hd); } else { return accu; @@ -811,7 +811,7 @@ function reduceWithIndex(l, acc, f) { let i = _i; let acc$1 = _acc; let l$1 = _l; - if (!l$1) { + if (l$1 === 0) { return acc$1; } _i = i + 1 | 0; @@ -829,10 +829,10 @@ function mapReverse2(l1, l2, f) { let accu = _accu; let l2$1 = _l2; let l1$1 = _l1; - if (!l1$1) { + if (l1$1 === 0) { return accu; } - if (!l2$1) { + if (l2$1 === 0) { return accu; } _accu = { @@ -849,10 +849,10 @@ function forEach2(_l1, _l2, f) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return; } - if (!l2) { + if (l2 === 0) { return; } f(l1.hd, l2.hd); @@ -867,10 +867,10 @@ function reduce2(_l1, _l2, _accu, f) { let accu = _accu; let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return accu; } - if (!l2) { + if (l2 === 0) { return accu; } _accu = f(accu, l1.hd, l2.hd); @@ -881,7 +881,7 @@ function reduce2(_l1, _l2, _accu, f) { } function reduceReverse2Unsafe(l1, l2, accu, f) { - if (l1 && l2) { + if (l1 !== 0 && l2 !== 0) { return f(reduceReverse2Unsafe(l1.tl, l2.tl, accu, f), l1.hd, l2.hd); } else { return accu; @@ -907,7 +907,7 @@ function reduceReverse2(l1, l2, acc, f) { function every(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return true; } if (!p(xs.hd)) { @@ -921,7 +921,7 @@ function every(_xs, p) { function some(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return false; } if (p(xs.hd)) { @@ -936,10 +936,10 @@ function every2(_l1, _l2, p) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return true; } - if (!l2) { + if (l2 === 0) { return true; } if (!p(l1.hd, l2.hd)) { @@ -955,14 +955,14 @@ function compareLength(_l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { - if (l2) { + if (l1 === 0) { + if (l2 !== 0) { return -1; } else { return 0; } } - if (!l2) { + if (l2 === 0) { return 1; } _l2 = l2.tl; @@ -975,14 +975,14 @@ function compare(_l1, _l2, p) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { - if (l2) { + if (l1 === 0) { + if (l2 !== 0) { return -1; } else { return 0; } } - if (!l2) { + if (l2 === 0) { return 1; } let c = p(l1.hd, l2.hd); @@ -999,10 +999,10 @@ function equal(_l1, _l2, p) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { - return !l2; + if (l1 === 0) { + return l2 === 0; } - if (!l2) { + if (l2 === 0) { return false; } if (!p(l1.hd, l2.hd)) { @@ -1018,10 +1018,10 @@ function some2(_l1, _l2, p) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return false; } - if (!l2) { + if (l2 === 0) { return false; } if (p(l1.hd, l2.hd)) { @@ -1036,7 +1036,7 @@ function some2(_l1, _l2, p) { function has(_xs, x, eq) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return false; } if (eq(xs.hd, x)) { @@ -1050,7 +1050,7 @@ function has(_xs, x, eq) { function getAssoc(_xs, x, eq) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return; } let match = xs.hd; @@ -1065,7 +1065,7 @@ function getAssoc(_xs, x, eq) { function hasAssoc(_xs, x, eq) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return false; } if (eq(xs.hd[0], x)) { @@ -1077,7 +1077,7 @@ function hasAssoc(_xs, x, eq) { } function removeAssoc(xs, x, eq) { - if (!xs) { + if (xs === 0) { return /* [] */0; } let l = xs.tl; @@ -1098,7 +1098,7 @@ function removeAssoc(xs, x, eq) { } function setAssoc(xs, x, k, eq) { - if (!xs) { + if (xs === 0) { return { hd: [ x, @@ -1145,7 +1145,7 @@ function sort(xs, cmp) { function find(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return; } let x = xs.hd; @@ -1160,7 +1160,7 @@ function find(_xs, p) { function filter(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return /* [] */0; } let t = xs.tl; @@ -1184,7 +1184,7 @@ function filterWithIndex(xs, p) { while (true) { let i = _i; let xs$1 = _xs; - if (!xs$1) { + if (xs$1 === 0) { return /* [] */0; } let t = xs$1.tl; @@ -1206,7 +1206,7 @@ function filterWithIndex(xs, p) { function filterMap(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return /* [] */0; } let t = xs.tl; @@ -1225,7 +1225,7 @@ function filterMap(_xs, p) { } function partition(l, p) { - if (!l) { + if (l === 0) { return [ /* [] */0, /* [] */0 @@ -1256,7 +1256,7 @@ function partition(l, p) { } function unzip(xs) { - if (!xs) { + if (xs === 0) { return [ /* [] */0, /* [] */0 @@ -1279,10 +1279,10 @@ function unzip(xs) { } function zip(l1, l2) { - if (!l1) { + if (l1 === 0) { return /* [] */0; } - if (!l2) { + if (l2 === 0) { return /* [] */0; } let cell = { diff --git a/lib/es6/Pervasives.js b/lib/es6/Pervasives.js index 5c493d7ea9..65fe437b38 100644 --- a/lib/es6/Pervasives.js +++ b/lib/es6/Pervasives.js @@ -107,7 +107,7 @@ function int_of_string_opt(s) { } function $at(l1, l2) { - if (l1) { + if (l1 !== 0) { return { hd: l1.hd, tl: $at(l1.tl, l2) diff --git a/lib/js/Belt_List.js b/lib/js/Belt_List.js index 2d9f0e17ec..0dd1ac9145 100644 --- a/lib/js/Belt_List.js +++ b/lib/js/Belt_List.js @@ -5,14 +5,14 @@ let Belt_SortArray = require("./Belt_SortArray.js"); let Primitive_option = require("./Primitive_option.js"); function head(x) { - if (x) { + if (x !== 0) { return Primitive_option.some(x.hd); } } function headExn(x) { - if (x) { + if (x !== 0) { return x.hd; } throw { @@ -22,14 +22,14 @@ function headExn(x) { } function tail(x) { - if (x) { + if (x !== 0) { return x.tl; } } function tailExn(x) { - if (x) { + if (x !== 0) { return x.tl; } throw { @@ -54,7 +54,7 @@ function get(x, n) { while (true) { let n$1 = _n; let x$1 = _x; - if (!x$1) { + if (x$1 === 0) { return; } if (n$1 === 0) { @@ -79,7 +79,7 @@ function getExn(x, n) { while (true) { let n$1 = _n; let x$1 = _x; - if (x$1) { + if (x$1 !== 0) { if (n$1 === 0) { return x$1.hd; } @@ -99,7 +99,7 @@ function partitionAux(p, _cell, _precX, _precY) { let precY = _precY; let precX = _precX; let cell = _cell; - if (!cell) { + if (cell === 0) { return; } let t = cell.tl; @@ -126,7 +126,7 @@ function splitAux(_cell, _precX, _precY) { let precY = _precY; let precX = _precX; let cell = _cell; - if (!cell) { + if (cell === 0) { return; } let match = cell.hd; @@ -151,7 +151,7 @@ function copyAuxCont(_cellX, _prec) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return prec; } let next = { @@ -169,7 +169,7 @@ function copyAuxWitFilter(f, _cellX, _prec) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } let t = cellX.tl; @@ -194,7 +194,7 @@ function copyAuxWithFilterIndex(f, _cellX, _prec, _i) { let i = _i; let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } let t = cellX.tl; @@ -220,7 +220,7 @@ function copyAuxWitFilterMap(f, _cellX, _prec) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } let t = cellX.tl; @@ -244,7 +244,7 @@ function removeAssocAuxWithMap(_cellX, x, _prec, f) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return false; } let t = cellX.tl; @@ -268,7 +268,7 @@ function setAssocAuxWithMap(_cellX, x, k, _prec, eq) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return false; } let t = cellX.tl; @@ -298,7 +298,7 @@ function copyAuxWithMap(_cellX, _prec, f) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } let next = { @@ -317,10 +317,10 @@ function zipAux(_cellX, _cellY, _prec) { let prec = _prec; let cellY = _cellY; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } - if (!cellY) { + if (cellY === 0) { return; } let next = { @@ -343,10 +343,10 @@ function copyAuxWithMap2(f, _cellX, _cellY, _prec) { let prec = _prec; let cellY = _cellY; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } - if (!cellY) { + if (cellY === 0) { return; } let next = { @@ -366,7 +366,7 @@ function copyAuxWithMapI(f, _i, _cellX, _prec) { let prec = _prec; let cellX = _cellX; let i = _i; - if (!cellX) { + if (cellX === 0) { return; } let next = { @@ -389,7 +389,7 @@ function takeAux(_n, _cell, _prec) { if (n === 0) { return true; } - if (!cell) { + if (cell === 0) { return false; } let cell$1 = { @@ -412,7 +412,7 @@ function splitAtAux(_n, _cell, _prec) { if (n === 0) { return cell; } - if (!cell) { + if (cell === 0) { return; } let cell$1 = { @@ -434,7 +434,7 @@ function take(lst, n) { if (n === 0) { return /* [] */0; } - if (!lst) { + if (lst === 0) { return; } let cell = { @@ -460,7 +460,7 @@ function drop(lst, n) { if (n$1 === 0) { return l; } - if (!l) { + if (l === 0) { return; } _n = n$1 - 1 | 0; @@ -480,7 +480,7 @@ function splitAt(lst, n) { lst ]; } - if (!lst) { + if (lst === 0) { return; } let cell = { @@ -498,7 +498,7 @@ function splitAt(lst, n) { } function concat(xs, ys) { - if (!xs) { + if (xs === 0) { return ys; } let cell = { @@ -510,7 +510,7 @@ function concat(xs, ys) { } function map(xs, f) { - if (!xs) { + if (xs === 0) { return /* [] */0; } let cell = { @@ -522,10 +522,10 @@ function map(xs, f) { } function zipBy(l1, l2, f) { - if (!l1) { + if (l1 === 0) { return /* [] */0; } - if (!l2) { + if (l2 === 0) { return /* [] */0; } let cell = { @@ -537,7 +537,7 @@ function zipBy(l1, l2, f) { } function mapWithIndex(xs, f) { - if (!xs) { + if (xs === 0) { return /* [] */0; } let cell = { @@ -598,7 +598,7 @@ function length(xs) { while (true) { let acc = _acc; let x = _x; - if (!x) { + if (x === 0) { return acc; } _acc = acc + 1 | 0; @@ -611,7 +611,7 @@ function fillAux(arr, _i, _x) { while (true) { let x = _x; let i = _i; - if (!x) { + if (x === 0) { return; } arr[i] = x.hd; @@ -656,7 +656,7 @@ function reverseConcat(_l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return l2; } _l2 = { @@ -676,7 +676,7 @@ function flattenAux(_prec, _xs) { while (true) { let xs = _xs; let prec = _prec; - if (xs) { + if (xs !== 0) { _xs = xs.tl; _prec = copyAuxCont(xs.hd, prec); continue; @@ -689,11 +689,11 @@ function flattenAux(_prec, _xs) { function flatten(_xs) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return /* [] */0; } let match = xs.hd; - if (match) { + if (match !== 0) { let cell = { hd: match.hd, tl: /* [] */0 @@ -728,7 +728,7 @@ function mapReverse(l, f) { while (true) { let xs = _xs; let accu = _accu; - if (!xs) { + if (xs === 0) { return accu; } _xs = xs.tl; @@ -743,7 +743,7 @@ function mapReverse(l, f) { function forEach(_xs, f) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return; } f(xs.hd); @@ -758,7 +758,7 @@ function forEachWithIndex(l, f) { while (true) { let i = _i; let xs = _xs; - if (!xs) { + if (xs === 0) { return; } f(i, xs.hd); @@ -772,7 +772,7 @@ function reduce(_l, _accu, f) { while (true) { let accu = _accu; let l = _l; - if (!l) { + if (l === 0) { return accu; } _accu = f(accu, l.hd); @@ -782,7 +782,7 @@ function reduce(_l, _accu, f) { } function reduceReverseUnsafe(l, accu, f) { - if (l) { + if (l !== 0) { return f(reduceReverseUnsafe(l.tl, accu, f), l.hd); } else { return accu; @@ -806,7 +806,7 @@ function reduceWithIndex(l, acc, f) { let i = _i; let acc$1 = _acc; let l$1 = _l; - if (!l$1) { + if (l$1 === 0) { return acc$1; } _i = i + 1 | 0; @@ -824,10 +824,10 @@ function mapReverse2(l1, l2, f) { let accu = _accu; let l2$1 = _l2; let l1$1 = _l1; - if (!l1$1) { + if (l1$1 === 0) { return accu; } - if (!l2$1) { + if (l2$1 === 0) { return accu; } _accu = { @@ -844,10 +844,10 @@ function forEach2(_l1, _l2, f) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return; } - if (!l2) { + if (l2 === 0) { return; } f(l1.hd, l2.hd); @@ -862,10 +862,10 @@ function reduce2(_l1, _l2, _accu, f) { let accu = _accu; let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return accu; } - if (!l2) { + if (l2 === 0) { return accu; } _accu = f(accu, l1.hd, l2.hd); @@ -876,7 +876,7 @@ function reduce2(_l1, _l2, _accu, f) { } function reduceReverse2Unsafe(l1, l2, accu, f) { - if (l1 && l2) { + if (l1 !== 0 && l2 !== 0) { return f(reduceReverse2Unsafe(l1.tl, l2.tl, accu, f), l1.hd, l2.hd); } else { return accu; @@ -895,7 +895,7 @@ function reduceReverse2(l1, l2, acc, f) { function every(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return true; } if (!p(xs.hd)) { @@ -909,7 +909,7 @@ function every(_xs, p) { function some(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return false; } if (p(xs.hd)) { @@ -924,10 +924,10 @@ function every2(_l1, _l2, p) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return true; } - if (!l2) { + if (l2 === 0) { return true; } if (!p(l1.hd, l2.hd)) { @@ -943,14 +943,14 @@ function cmpByLength(_l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { - if (l2) { + if (l1 === 0) { + if (l2 !== 0) { return -1; } else { return 0; } } - if (!l2) { + if (l2 === 0) { return 1; } _l2 = l2.tl; @@ -963,14 +963,14 @@ function cmp(_l1, _l2, p) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { - if (l2) { + if (l1 === 0) { + if (l2 !== 0) { return -1; } else { return 0; } } - if (!l2) { + if (l2 === 0) { return 1; } let c = p(l1.hd, l2.hd); @@ -987,10 +987,10 @@ function eq(_l1, _l2, p) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { - return !l2; + if (l1 === 0) { + return l2 === 0; } - if (!l2) { + if (l2 === 0) { return false; } if (!p(l1.hd, l2.hd)) { @@ -1006,10 +1006,10 @@ function some2(_l1, _l2, p) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return false; } - if (!l2) { + if (l2 === 0) { return false; } if (p(l1.hd, l2.hd)) { @@ -1024,7 +1024,7 @@ function some2(_l1, _l2, p) { function has(_xs, x, eq) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return false; } if (eq(xs.hd, x)) { @@ -1038,7 +1038,7 @@ function has(_xs, x, eq) { function getAssoc(_xs, x, eq) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return; } let match = xs.hd; @@ -1053,7 +1053,7 @@ function getAssoc(_xs, x, eq) { function hasAssoc(_xs, x, eq) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return false; } if (eq(xs.hd[0], x)) { @@ -1065,7 +1065,7 @@ function hasAssoc(_xs, x, eq) { } function removeAssoc(xs, x, eq) { - if (!xs) { + if (xs === 0) { return /* [] */0; } let l = xs.tl; @@ -1086,7 +1086,7 @@ function removeAssoc(xs, x, eq) { } function setAssoc(xs, x, k, eq) { - if (!xs) { + if (xs === 0) { return { hd: [ x, @@ -1133,7 +1133,7 @@ function sort(xs, cmp) { function getBy(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return; } let x = xs.hd; @@ -1148,7 +1148,7 @@ function getBy(_xs, p) { function keep(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return /* [] */0; } let t = xs.tl; @@ -1172,7 +1172,7 @@ function keepWithIndex(xs, p) { while (true) { let i = _i; let xs$1 = _xs; - if (!xs$1) { + if (xs$1 === 0) { return /* [] */0; } let t = xs$1.tl; @@ -1194,7 +1194,7 @@ function keepWithIndex(xs, p) { function keepMap(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return /* [] */0; } let t = xs.tl; @@ -1213,7 +1213,7 @@ function keepMap(_xs, p) { } function partition(l, p) { - if (!l) { + if (l === 0) { return [ /* [] */0, /* [] */0 @@ -1244,7 +1244,7 @@ function partition(l, p) { } function unzip(xs) { - if (!xs) { + if (xs === 0) { return [ /* [] */0, /* [] */0 @@ -1267,10 +1267,10 @@ function unzip(xs) { } function zip(l1, l2) { - if (!l1) { + if (l1 === 0) { return /* [] */0; } - if (!l2) { + if (l2 === 0) { return /* [] */0; } let cell = { diff --git a/lib/js/Belt_internalAVLset.js b/lib/js/Belt_internalAVLset.js index 6e17ca2e5f..ccffdcd473 100644 --- a/lib/js/Belt_internalAVLset.js +++ b/lib/js/Belt_internalAVLset.js @@ -589,10 +589,10 @@ function cmp(s1, s2, cmp$1) { while (true) { let e2 = _e2; let e1 = _e1; - if (!e1) { + if (e1 === 0) { return 0; } - if (!e2) { + if (e2 === 0) { return 0; } let h2 = e2.hd; diff --git a/lib/js/Belt_internalAVLtree.js b/lib/js/Belt_internalAVLtree.js index 278f2a4141..b0b3d3f3e5 100644 --- a/lib/js/Belt_internalAVLtree.js +++ b/lib/js/Belt_internalAVLtree.js @@ -749,10 +749,10 @@ function cmp(s1, s2, kcmp, vcmp) { while (true) { let e2 = _e2; let e1 = _e1; - if (!e1) { + if (e1 === 0) { return 0; } - if (!e2) { + if (e2 === 0) { return 0; } let h2 = e2.hd; @@ -785,10 +785,10 @@ function eq(s1, s2, kcmp, veq) { while (true) { let e2 = _e2; let e1 = _e1; - if (!e1) { + if (e1 === 0) { return true; } - if (!e2) { + if (e2 === 0) { return true; } let h2 = e2.hd; diff --git a/lib/js/Belt_internalMapInt.js b/lib/js/Belt_internalMapInt.js index 2bf62458d1..ed9658e9bb 100644 --- a/lib/js/Belt_internalMapInt.js +++ b/lib/js/Belt_internalMapInt.js @@ -211,10 +211,10 @@ function compareAux(_e1, _e2, vcmp) { while (true) { let e2 = _e2; let e1 = _e1; - if (!e1) { + if (e1 === 0) { return 0; } - if (!e2) { + if (e2 === 0) { return 0; } let h2 = e2.hd; @@ -249,10 +249,10 @@ function eqAux(_e1, _e2, eq) { while (true) { let e2 = _e2; let e1 = _e1; - if (!e1) { + if (e1 === 0) { return true; } - if (!e2) { + if (e2 === 0) { return true; } let h2 = e2.hd; diff --git a/lib/js/Belt_internalMapString.js b/lib/js/Belt_internalMapString.js index 6d75fd58be..e648ebefd7 100644 --- a/lib/js/Belt_internalMapString.js +++ b/lib/js/Belt_internalMapString.js @@ -211,10 +211,10 @@ function compareAux(_e1, _e2, vcmp) { while (true) { let e2 = _e2; let e1 = _e1; - if (!e1) { + if (e1 === 0) { return 0; } - if (!e2) { + if (e2 === 0) { return 0; } let h2 = e2.hd; @@ -249,10 +249,10 @@ function eqAux(_e1, _e2, eq) { while (true) { let e2 = _e2; let e1 = _e1; - if (!e1) { + if (e1 === 0) { return true; } - if (!e2) { + if (e2 === 0) { return true; } let h2 = e2.hd; diff --git a/lib/js/Belt_internalSetInt.js b/lib/js/Belt_internalSetInt.js index b6812e6e55..093dca6bd1 100644 --- a/lib/js/Belt_internalSetInt.js +++ b/lib/js/Belt_internalSetInt.js @@ -22,10 +22,10 @@ function compareAux(_e1, _e2) { while (true) { let e2 = _e2; let e1 = _e1; - if (!e1) { + if (e1 === 0) { return 0; } - if (!e2) { + if (e2 === 0) { return 0; } let h2 = e2.hd; diff --git a/lib/js/Belt_internalSetString.js b/lib/js/Belt_internalSetString.js index ec5c44986f..d08cce4212 100644 --- a/lib/js/Belt_internalSetString.js +++ b/lib/js/Belt_internalSetString.js @@ -22,10 +22,10 @@ function compareAux(_e1, _e2) { while (true) { let e2 = _e2; let e1 = _e1; - if (!e1) { + if (e1 === 0) { return 0; } - if (!e2) { + if (e2 === 0) { return 0; } let h2 = e2.hd; diff --git a/lib/js/Js_dict.js b/lib/js/Js_dict.js index 5b434b5b41..d696550db9 100644 --- a/lib/js/Js_dict.js +++ b/lib/js/Js_dict.js @@ -42,7 +42,7 @@ function fromList(entries) { let _x = entries; while (true) { let x = _x; - if (!x) { + if (x === 0) { return dict; } let match = x.hd; diff --git a/lib/js/List.js b/lib/js/List.js index 8e8cd35fbc..b11ab0d3ff 100644 --- a/lib/js/List.js +++ b/lib/js/List.js @@ -5,14 +5,14 @@ let Primitive_int = require("./Primitive_int.js"); let Primitive_option = require("./Primitive_option.js"); function head(x) { - if (x) { + if (x !== 0) { return Primitive_option.some(x.hd); } } function headExn(x) { - if (x) { + if (x !== 0) { return x.hd; } throw { @@ -22,14 +22,14 @@ function headExn(x) { } function tail(x) { - if (x) { + if (x !== 0) { return x.tl; } } function tailExn(x) { - if (x) { + if (x !== 0) { return x.tl; } throw { @@ -54,7 +54,7 @@ function get(x, n) { while (true) { let n$1 = _n; let x$1 = _x; - if (!x$1) { + if (x$1 === 0) { return; } if (n$1 === 0) { @@ -79,7 +79,7 @@ function getExn(x, n) { while (true) { let n$1 = _n; let x$1 = _x; - if (x$1) { + if (x$1 !== 0) { if (n$1 === 0) { return x$1.hd; } @@ -99,7 +99,7 @@ function partitionAux(p, _cell, _precX, _precY) { let precY = _precY; let precX = _precX; let cell = _cell; - if (!cell) { + if (cell === 0) { return; } let t = cell.tl; @@ -126,7 +126,7 @@ function splitAux(_cell, _precX, _precY) { let precY = _precY; let precX = _precX; let cell = _cell; - if (!cell) { + if (cell === 0) { return; } let match = cell.hd; @@ -151,7 +151,7 @@ function copyAuxCont(_cellX, _prec) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return prec; } let next = { @@ -169,7 +169,7 @@ function copyAuxWitFilter(f, _cellX, _prec) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } let t = cellX.tl; @@ -194,7 +194,7 @@ function copyAuxWithFilterIndex(f, _cellX, _prec, _i) { let i = _i; let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } let t = cellX.tl; @@ -220,7 +220,7 @@ function copyAuxWitFilterMap(f, _cellX, _prec) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } let t = cellX.tl; @@ -244,7 +244,7 @@ function removeAssocAuxWithMap(_cellX, x, _prec, f) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return false; } let t = cellX.tl; @@ -268,7 +268,7 @@ function setAssocAuxWithMap(_cellX, x, k, _prec, eq) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return false; } let t = cellX.tl; @@ -298,7 +298,7 @@ function copyAuxWithMap(_cellX, _prec, f) { while (true) { let prec = _prec; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } let next = { @@ -317,10 +317,10 @@ function zipAux(_cellX, _cellY, _prec) { let prec = _prec; let cellY = _cellY; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } - if (!cellY) { + if (cellY === 0) { return; } let next = { @@ -343,10 +343,10 @@ function copyAuxWithMap2(f, _cellX, _cellY, _prec) { let prec = _prec; let cellY = _cellY; let cellX = _cellX; - if (!cellX) { + if (cellX === 0) { return; } - if (!cellY) { + if (cellY === 0) { return; } let next = { @@ -366,7 +366,7 @@ function copyAuxWithMapI(f, _i, _cellX, _prec) { let prec = _prec; let cellX = _cellX; let i = _i; - if (!cellX) { + if (cellX === 0) { return; } let next = { @@ -389,7 +389,7 @@ function takeAux(_n, _cell, _prec) { if (n === 0) { return true; } - if (!cell) { + if (cell === 0) { return false; } let cell$1 = { @@ -412,7 +412,7 @@ function splitAtAux(_n, _cell, _prec) { if (n === 0) { return cell; } - if (!cell) { + if (cell === 0) { return; } let cell$1 = { @@ -434,7 +434,7 @@ function take(lst, n) { if (n === 0) { return /* [] */0; } - if (!lst) { + if (lst === 0) { return; } let cell = { @@ -460,7 +460,7 @@ function drop(lst, n) { if (n$1 === 0) { return l; } - if (!l) { + if (l === 0) { return; } _n = n$1 - 1 | 0; @@ -480,7 +480,7 @@ function splitAt(lst, n) { lst ]; } - if (!lst) { + if (lst === 0) { return; } let cell = { @@ -498,7 +498,7 @@ function splitAt(lst, n) { } function concat(xs, ys) { - if (!xs) { + if (xs === 0) { return ys; } let cell = { @@ -510,7 +510,7 @@ function concat(xs, ys) { } function map(xs, f) { - if (!xs) { + if (xs === 0) { return /* [] */0; } let cell = { @@ -522,10 +522,10 @@ function map(xs, f) { } function zipBy(l1, l2, f) { - if (!l1) { + if (l1 === 0) { return /* [] */0; } - if (!l2) { + if (l2 === 0) { return /* [] */0; } let cell = { @@ -537,7 +537,7 @@ function zipBy(l1, l2, f) { } function mapWithIndex(xs, f) { - if (!xs) { + if (xs === 0) { return /* [] */0; } let cell = { @@ -598,7 +598,7 @@ function length(xs) { while (true) { let acc = _acc; let x = _x; - if (!x) { + if (x === 0) { return acc; } _acc = acc + 1 | 0; @@ -611,7 +611,7 @@ function fillAux(arr, _i, _x) { while (true) { let x = _x; let i = _i; - if (!x) { + if (x === 0) { return; } arr[i] = x.hd; @@ -656,7 +656,7 @@ function reverseConcat(_l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return l2; } _l2 = { @@ -676,7 +676,7 @@ function flatAux(_prec, _xs) { while (true) { let xs = _xs; let prec = _prec; - if (xs) { + if (xs !== 0) { _xs = xs.tl; _prec = copyAuxCont(xs.hd, prec); continue; @@ -689,11 +689,11 @@ function flatAux(_prec, _xs) { function flat(_xs) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return /* [] */0; } let match = xs.hd; - if (match) { + if (match !== 0) { let cell = { hd: match.hd, tl: /* [] */0 @@ -728,7 +728,7 @@ function mapReverse(l, f) { while (true) { let xs = _xs; let accu = _accu; - if (!xs) { + if (xs === 0) { return accu; } _xs = xs.tl; @@ -743,7 +743,7 @@ function mapReverse(l, f) { function forEach(_xs, f) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return; } f(xs.hd); @@ -758,7 +758,7 @@ function forEachWithIndex(l, f) { while (true) { let i = _i; let xs = _xs; - if (!xs) { + if (xs === 0) { return; } f(xs.hd, i); @@ -772,7 +772,7 @@ function reduce(_l, _accu, f) { while (true) { let accu = _accu; let l = _l; - if (!l) { + if (l === 0) { return accu; } _accu = f(accu, l.hd); @@ -782,7 +782,7 @@ function reduce(_l, _accu, f) { } function reduceReverseUnsafe(l, accu, f) { - if (l) { + if (l !== 0) { return f(reduceReverseUnsafe(l.tl, accu, f), l.hd); } else { return accu; @@ -811,7 +811,7 @@ function reduceWithIndex(l, acc, f) { let i = _i; let acc$1 = _acc; let l$1 = _l; - if (!l$1) { + if (l$1 === 0) { return acc$1; } _i = i + 1 | 0; @@ -829,10 +829,10 @@ function mapReverse2(l1, l2, f) { let accu = _accu; let l2$1 = _l2; let l1$1 = _l1; - if (!l1$1) { + if (l1$1 === 0) { return accu; } - if (!l2$1) { + if (l2$1 === 0) { return accu; } _accu = { @@ -849,10 +849,10 @@ function forEach2(_l1, _l2, f) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return; } - if (!l2) { + if (l2 === 0) { return; } f(l1.hd, l2.hd); @@ -867,10 +867,10 @@ function reduce2(_l1, _l2, _accu, f) { let accu = _accu; let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return accu; } - if (!l2) { + if (l2 === 0) { return accu; } _accu = f(accu, l1.hd, l2.hd); @@ -881,7 +881,7 @@ function reduce2(_l1, _l2, _accu, f) { } function reduceReverse2Unsafe(l1, l2, accu, f) { - if (l1 && l2) { + if (l1 !== 0 && l2 !== 0) { return f(reduceReverse2Unsafe(l1.tl, l2.tl, accu, f), l1.hd, l2.hd); } else { return accu; @@ -907,7 +907,7 @@ function reduceReverse2(l1, l2, acc, f) { function every(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return true; } if (!p(xs.hd)) { @@ -921,7 +921,7 @@ function every(_xs, p) { function some(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return false; } if (p(xs.hd)) { @@ -936,10 +936,10 @@ function every2(_l1, _l2, p) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return true; } - if (!l2) { + if (l2 === 0) { return true; } if (!p(l1.hd, l2.hd)) { @@ -955,14 +955,14 @@ function compareLength(_l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { - if (l2) { + if (l1 === 0) { + if (l2 !== 0) { return -1; } else { return 0; } } - if (!l2) { + if (l2 === 0) { return 1; } _l2 = l2.tl; @@ -975,14 +975,14 @@ function compare(_l1, _l2, p) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { - if (l2) { + if (l1 === 0) { + if (l2 !== 0) { return -1; } else { return 0; } } - if (!l2) { + if (l2 === 0) { return 1; } let c = p(l1.hd, l2.hd); @@ -999,10 +999,10 @@ function equal(_l1, _l2, p) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { - return !l2; + if (l1 === 0) { + return l2 === 0; } - if (!l2) { + if (l2 === 0) { return false; } if (!p(l1.hd, l2.hd)) { @@ -1018,10 +1018,10 @@ function some2(_l1, _l2, p) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return false; } - if (!l2) { + if (l2 === 0) { return false; } if (p(l1.hd, l2.hd)) { @@ -1036,7 +1036,7 @@ function some2(_l1, _l2, p) { function has(_xs, x, eq) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return false; } if (eq(xs.hd, x)) { @@ -1050,7 +1050,7 @@ function has(_xs, x, eq) { function getAssoc(_xs, x, eq) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return; } let match = xs.hd; @@ -1065,7 +1065,7 @@ function getAssoc(_xs, x, eq) { function hasAssoc(_xs, x, eq) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return false; } if (eq(xs.hd[0], x)) { @@ -1077,7 +1077,7 @@ function hasAssoc(_xs, x, eq) { } function removeAssoc(xs, x, eq) { - if (!xs) { + if (xs === 0) { return /* [] */0; } let l = xs.tl; @@ -1098,7 +1098,7 @@ function removeAssoc(xs, x, eq) { } function setAssoc(xs, x, k, eq) { - if (!xs) { + if (xs === 0) { return { hd: [ x, @@ -1145,7 +1145,7 @@ function sort(xs, cmp) { function find(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return; } let x = xs.hd; @@ -1160,7 +1160,7 @@ function find(_xs, p) { function filter(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return /* [] */0; } let t = xs.tl; @@ -1184,7 +1184,7 @@ function filterWithIndex(xs, p) { while (true) { let i = _i; let xs$1 = _xs; - if (!xs$1) { + if (xs$1 === 0) { return /* [] */0; } let t = xs$1.tl; @@ -1206,7 +1206,7 @@ function filterWithIndex(xs, p) { function filterMap(_xs, p) { while (true) { let xs = _xs; - if (!xs) { + if (xs === 0) { return /* [] */0; } let t = xs.tl; @@ -1225,7 +1225,7 @@ function filterMap(_xs, p) { } function partition(l, p) { - if (!l) { + if (l === 0) { return [ /* [] */0, /* [] */0 @@ -1256,7 +1256,7 @@ function partition(l, p) { } function unzip(xs) { - if (!xs) { + if (xs === 0) { return [ /* [] */0, /* [] */0 @@ -1279,10 +1279,10 @@ function unzip(xs) { } function zip(l1, l2) { - if (!l1) { + if (l1 === 0) { return /* [] */0; } - if (!l2) { + if (l2 === 0) { return /* [] */0; } let cell = { diff --git a/lib/js/Pervasives.js b/lib/js/Pervasives.js index 35d21521a1..bc1fb820b4 100644 --- a/lib/js/Pervasives.js +++ b/lib/js/Pervasives.js @@ -107,7 +107,7 @@ function int_of_string_opt(s) { } function $at(l1, l2) { - if (l1) { + if (l1 !== 0) { return { hd: l1.hd, tl: $at(l1.tl, l2) diff --git a/tests/docstring_tests/DocTest.res.mjs b/tests/docstring_tests/DocTest.res.mjs index 399c0b537c..aa63b8065b 100644 --- a/tests/docstring_tests/DocTest.res.mjs +++ b/tests/docstring_tests/DocTest.res.mjs @@ -73,7 +73,7 @@ function getExamples(param) { while (true) { let acc = _acc; let items = _items; - if (!items) { + if (items === 0) { return acc; } let match = items.hd; @@ -158,7 +158,7 @@ function getCodeBlocks(example) { while (true) { let acc = _acc; let lines = _lines; - if (!lines) { + if (lines === 0) { return Pervasives.panic("Failed to find end of code block for " + example.kind + ": " + example.id); } let hd = lines.hd; @@ -177,7 +177,7 @@ function getCodeBlocks(example) { while (true) { let acc = _acc; let lines = _lines; - if (!lines) { + if (lines === 0) { return acc; } let rest = lines.tl; diff --git a/tests/tests/src/bdd.mjs b/tests/tests/src/bdd.mjs index ea08036d64..63e0a8bcdb 100644 --- a/tests/tests/src/bdd.mjs +++ b/tests/tests/src/bdd.mjs @@ -57,7 +57,7 @@ function resize(newSize) { let copyBucket = _bucket => { while (true) { let bucket = _bucket; - if (!bucket) { + if (bucket === 0) { return; } let n = bucket.hd; @@ -135,7 +135,7 @@ function mkNode(low, v, high) { let _b = bucket; while (true) { let b = _b; - if (b) { + if (b !== 0) { let n = b.hd; if (typeof n !== "object") { if (n === "One") { diff --git a/tests/tests/src/exception_raise_test.mjs b/tests/tests/src/exception_raise_test.mjs index 571bbff0e5..4f1f9dd08f 100644 --- a/tests/tests/src/exception_raise_test.mjs +++ b/tests/tests/src/exception_raise_test.mjs @@ -38,15 +38,15 @@ function appf(g, x) { } } let match = exn._1; - if (!match) { + if (match === 0) { return 4; } let match$1 = match.tl; - if (!match$1) { + if (match$1 === 0) { return 4; } let match$2 = match$1.tl; - if (match$2) { + if (match$2 !== 0) { return match$2.hd; } else { return 4; diff --git a/tests/tests/src/ext_array_test.mjs b/tests/tests/src/ext_array_test.mjs index 0ca8a94fe9..ec0dac2c80 100644 --- a/tests/tests/src/ext_array_test.mjs +++ b/tests/tests/src/ext_array_test.mjs @@ -33,7 +33,7 @@ function reverse(a) { } function reverse_of_list(x) { - if (!x) { + if (x === 0) { return []; } let len = Belt_List.length(x); @@ -43,7 +43,7 @@ function reverse_of_list(x) { while (true) { let x$1 = _x; let i = _i; - if (!x$1) { + if (x$1 === 0) { return a; } a[(len - i | 0) - 2 | 0] = x$1.hd; @@ -146,7 +146,7 @@ function to_list_map_acc(f, a, acc) { } function of_list_map(f, a) { - if (!a) { + if (a === 0) { return []; } let tl = a.tl; @@ -158,7 +158,7 @@ function of_list_map(f, a) { while (true) { let x = _x; let i = _i; - if (!x) { + if (x === 0) { return arr; } arr[i] = f(x.hd); diff --git a/tests/tests/src/gpr_1150.mjs b/tests/tests/src/gpr_1150.mjs index 6485e77f1c..1d2b06f9f1 100644 --- a/tests/tests/src/gpr_1150.mjs +++ b/tests/tests/src/gpr_1150.mjs @@ -2,17 +2,17 @@ function f(children) { - if (!children) { + if (children === 0) { return []; } let children$1 = children.tl; let a0 = children.hd; - if (!children$1) { + if (children$1 === 0) { return [a0]; } let children$2 = children$1.tl; let a1 = children$1.hd; - if (!children$2) { + if (children$2 === 0) { return [ a0, a1 @@ -20,7 +20,7 @@ function f(children) { } let children$3 = children$2.tl; let a2 = children$2.hd; - if (!children$3) { + if (children$3 === 0) { return [ a0, a1, @@ -29,7 +29,7 @@ function f(children) { } let children$4 = children$3.tl; let a3 = children$3.hd; - if (!children$4) { + if (children$4 === 0) { return [ a0, a1, @@ -39,7 +39,7 @@ function f(children) { } let children$5 = children$4.tl; let a4 = children$4.hd; - if (!children$5) { + if (children$5 === 0) { return [ a0, a1, @@ -50,7 +50,7 @@ function f(children) { } let children$6 = children$5.tl; let a5 = children$5.hd; - if (!children$6) { + if (children$6 === 0) { return [ a0, a1, @@ -62,7 +62,7 @@ function f(children) { } let children$7 = children$6.tl; let a6 = children$6.hd; - if (!children$7) { + if (children$7 === 0) { return [ a0, a1, @@ -75,7 +75,7 @@ function f(children) { } let children$8 = children$7.tl; let a7 = children$7.hd; - if (!children$8) { + if (children$8 === 0) { return [ a0, a1, @@ -89,7 +89,7 @@ function f(children) { } let children$9 = children$8.tl; let a8 = children$8.hd; - if (!children$9) { + if (children$9 === 0) { return [ a0, a1, @@ -104,7 +104,7 @@ function f(children) { } let children$10 = children$9.tl; let a9 = children$9.hd; - if (!children$10) { + if (children$10 === 0) { return [ a0, a1, @@ -120,7 +120,7 @@ function f(children) { } let children$11 = children$10.tl; let a10 = children$10.hd; - if (!children$11) { + if (children$11 === 0) { return [ a0, a1, @@ -137,7 +137,7 @@ function f(children) { } let children$12 = children$11.tl; let a11 = children$11.hd; - if (!children$12) { + if (children$12 === 0) { return [ a0, a1, @@ -155,7 +155,7 @@ function f(children) { } let children$13 = children$12.tl; let a12 = children$12.hd; - if (!children$13) { + if (children$13 === 0) { return [ a0, a1, @@ -174,7 +174,7 @@ function f(children) { } let children$14 = children$13.tl; let a13 = children$13.hd; - if (!children$14) { + if (children$14 === 0) { return [ a0, a1, @@ -194,7 +194,7 @@ function f(children) { } let children$15 = children$14.tl; let a14 = children$14.hd; - if (!children$15) { + if (children$15 === 0) { return [ a0, a1, @@ -213,7 +213,7 @@ function f(children) { a14 ]; } - if (children$15.tl) { + if (children$15.tl !== 0) { throw { RE_EXN_ID: "Assert_failure", _1: [ diff --git a/tests/tests/src/gpr_4632.mjs b/tests/tests/src/gpr_4632.mjs index 66dfe24aac..c581a7090e 100644 --- a/tests/tests/src/gpr_4632.mjs +++ b/tests/tests/src/gpr_4632.mjs @@ -1,7 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -let T0_myList = { +let myList = { hd: 1, tl: { hd: 2, @@ -9,29 +9,77 @@ let T0_myList = { } }; -let T0_tail = { - hd: 2, - tl: /* [] */0 -}; +let T0; -let T0 = { - myList: T0_myList, - head: 1, - tail: T0_tail -}; +if (myList !== 0) { + T0 = { + myList: myList, + head: 1, + tail: { + hd: 2, + tl: /* [] */0 + } + }; +} else { + throw { + RE_EXN_ID: "Match_failure", + _1: [ + "gpr_4632.res", + 6, + 6 + ], + Error: new Error() + }; +} -throw { - RE_EXN_ID: "Match_failure", - _1: [ - "gpr_4632.res", - 12, - 6 +let myList$1 = { + hd: [ + 1, + 2, + 3 ], - Error: new Error() + tl: /* [] */0 }; +let T1; + +if (myList$1 !== 0) { + if (/* [] */0 !== 0) { + T1 = { + myList: myList$1, + h0: [ + 1, + 2, + 3 + ], + h1: /* [] */(0).hd, + h2: /* [] */(0).tl + }; + } else { + throw { + RE_EXN_ID: "Match_failure", + _1: [ + "gpr_4632.res", + 12, + 6 + ], + Error: new Error() + }; + } +} else { + throw { + RE_EXN_ID: "Match_failure", + _1: [ + "gpr_4632.res", + 12, + 6 + ], + Error: new Error() + }; +} + export { T0, T1, } -/* T1 Not a pure module */ +/* T0 Not a pure module */ diff --git a/tests/tests/src/gpr_4639_test.mjs b/tests/tests/src/gpr_4639_test.mjs index 6e281fb365..87774032ab 100644 --- a/tests/tests/src/gpr_4639_test.mjs +++ b/tests/tests/src/gpr_4639_test.mjs @@ -2,12 +2,12 @@ function x(url) { - if (!url) { + if (url === 0) { return "start"; } switch (url.hd) { case "login" : - if (url.tl) { + if (url.tl !== 0) { return "start"; } else { return "login"; diff --git a/tests/tests/src/mario_game.mjs b/tests/tests/src/mario_game.mjs index 3f460365a9..6086b07dfe 100644 --- a/tests/tests/src/mario_game.mjs +++ b/tests/tests/src/mario_game.mjs @@ -2098,7 +2098,7 @@ function check_collisions(collid, all_collids, state) { while (true) { let acc = _acc; let cs = _cs; - if (!cs) { + if (cs === 0) { return acc; } let h = cs.hd; @@ -2421,7 +2421,7 @@ let Director = { function mem_loc(checkloc, _loclist) { while (true) { let loclist = _loclist; - if (!loclist) { + if (loclist === 0) { return false; } if (Primitive_object.equal(checkloc, loclist.hd[1])) { @@ -2433,7 +2433,7 @@ function mem_loc(checkloc, _loclist) { } function convert_list(lst) { - if (!lst) { + if (lst === 0) { return /* [] */0; } let h = lst.hd; @@ -2485,7 +2485,7 @@ function choose_sblock_typ(typ) { function avoid_overlap(_lst, currentLst) { while (true) { let lst = _lst; - if (!lst) { + if (lst === 0) { return /* [] */0; } let t = lst.tl; @@ -2504,7 +2504,7 @@ function avoid_overlap(_lst, currentLst) { function trim_edges(_lst, blockw, blockh) { while (true) { let lst = _lst; - if (!lst) { + if (lst === 0) { return /* [] */0; } let t = lst.tl; @@ -2545,7 +2545,7 @@ function generate_coins(_block_coord) { while (true) { let block_coord = _block_coord; let place_coin = int(2); - if (!block_coord) { + if (block_coord === 0) { return /* [] */0; } let t = block_coord.tl; @@ -3037,7 +3037,7 @@ function generate_block_enemies(_block_coord) { let block_coord = _block_coord; let place_enemy = int(20); let enemy_typ = int(3); - if (!block_coord) { + if (block_coord === 0) { return /* [] */0; } let t = block_coord.tl; @@ -3149,7 +3149,7 @@ function generate_ground(blockw, blockh, _inc, _acc) { } function convert_to_block_obj(lst, context) { - if (!lst) { + if (lst === 0) { return /* [] */0; } let h = lst.hd; @@ -3165,7 +3165,7 @@ function convert_to_block_obj(lst, context) { } function convert_to_enemy_obj(lst, context) { - if (!lst) { + if (lst === 0) { return /* [] */0; } let h = lst.hd; @@ -3181,7 +3181,7 @@ function convert_to_enemy_obj(lst, context) { } function convert_to_coin_obj(lst, context) { - if (!lst) { + if (lst === 0) { return /* [] */0; } let ob = spawn({ diff --git a/tests/tests/src/mt.mjs b/tests/tests/src/mt.mjs index 1534dbe473..a10fd640a5 100644 --- a/tests/tests/src/mt.mjs +++ b/tests/tests/src/mt.mjs @@ -12,11 +12,11 @@ function assert_fail(msg) { function is_mocha() { let match = Belt_List.fromArray(Process.argv); - if (!match) { + if (match === 0) { return false; } let match$1 = match.tl; - if (!match$1) { + if (match$1 === 0) { return false; } let exec = Path.basename(match$1.hd); @@ -217,7 +217,7 @@ let from_promise_suites = (function from_promise_suites(name, suites) { function old_from_promise_suites_donotuse(name, suites) { let match = Belt_List.fromArray(Process.argv); - if (match) { + if (match !== 0) { if (is_mocha()) { describe(name, () => Belt_List.forEach(suites, param => { let code = param[1]; diff --git a/tests/tests/src/nested_pattern_match_test.mjs b/tests/tests/src/nested_pattern_match_test.mjs index 5fe0182b48..d15dc8b6d9 100644 --- a/tests/tests/src/nested_pattern_match_test.mjs +++ b/tests/tests/src/nested_pattern_match_test.mjs @@ -2,27 +2,27 @@ function f_list(x) { - if (!x) { + if (x === 0) { return 0; } let match = x.tl; - if (!match) { + if (match === 0) { return 0; } let match$1 = match.tl; - if (!match$1) { + if (match$1 === 0) { return 0; } let match$2 = match$1.tl; - if (!match$2) { + if (match$2 === 0) { return 0; } let match$3 = match$2.tl; - if (!match$3) { + if (match$3 === 0) { return 0; } let match$4 = match$3.tl; - if (match$4) { + if (match$4 !== 0) { return ((((x.hd + match.hd | 0) + match$1.hd | 0) + match$2.hd | 0) + match$3.hd | 0) + match$4.hd | 0; } else { return 0; @@ -49,21 +49,21 @@ function f_opion(x) { return 0; } let match$1 = x.lo; - if (!match$1) { + if (match$1 === 0) { return 0; } if (match$1.hd !== undefined) { return 0; } let match$2 = match$1.tl; - if (!match$2) { + if (match$2 === 0) { return 0; } if (match$2.hd !== undefined) { return 0; } let match$3 = match$2.tl; - if (!match$3) { + if (match$3 === 0) { return 0; } let match$4 = match$3.hd; @@ -74,7 +74,7 @@ function f_opion(x) { return 0; } let match$5 = match$3.tl; - if (!match$5) { + if (match$5 === 0) { return 0; } let match$6 = match$5.hd; @@ -85,28 +85,28 @@ function f_opion(x) { return 0; } let match$7 = match$5.tl; - if (match$7 && match$7.hd !== undefined) { + if (match$7 !== 0 && match$7.hd !== undefined) { return 2; } else { return 0; } } let match$8 = x.lo; - if (!match$8) { + if (match$8 === 0) { return 0; } if (match$8.hd !== undefined) { return 0; } let match$9 = match$8.tl; - if (!match$9) { + if (match$9 === 0) { return 0; } if (match$9.hd !== undefined) { return 0; } let match$10 = match$9.tl; - if (!match$10) { + if (match$10 === 0) { return 0; } let match$11 = match$10.hd; @@ -117,7 +117,7 @@ function f_opion(x) { return 0; } let match$12 = match$10.tl; - if (!match$12) { + if (match$12 === 0) { return 0; } let match$13 = match$12.hd; @@ -128,7 +128,7 @@ function f_opion(x) { return 0; } let match$14 = match$12.tl; - if (match$14 && match$14.hd !== undefined) { + if (match$14 !== 0 && match$14.hd !== undefined) { return 3; } else { return 0; diff --git a/tests/tests/src/ocaml_compat/Ocaml_Array.mjs b/tests/tests/src/ocaml_compat/Ocaml_Array.mjs index 7fb5f35aa4..6109a9cd14 100644 --- a/tests/tests/src/ocaml_compat/Ocaml_Array.mjs +++ b/tests/tests/src/ocaml_compat/Ocaml_Array.mjs @@ -157,7 +157,7 @@ function list_length(_accu, _param) { while (true) { let param = _param; let accu = _accu; - if (!param) { + if (param === 0) { return accu; } _param = param.tl; @@ -167,7 +167,7 @@ function list_length(_accu, _param) { } function of_list(param) { - if (!param) { + if (param === 0) { return []; } let hd = param.hd; @@ -178,7 +178,7 @@ function of_list(param) { while (true) { let param$1 = _param; let i = _i; - if (!param$1) { + if (param$1 === 0) { return a; } a[i] = param$1.hd; diff --git a/tests/tests/src/ocaml_compat/Ocaml_List.mjs b/tests/tests/src/ocaml_compat/Ocaml_List.mjs index 64703b8cd5..582cca5c84 100644 --- a/tests/tests/src/ocaml_compat/Ocaml_List.mjs +++ b/tests/tests/src/ocaml_compat/Ocaml_List.mjs @@ -9,7 +9,7 @@ function length(l) { while (true) { let param = _param; let len = _len; - if (!param) { + if (param === 0) { return len; } _param = param.tl; @@ -26,7 +26,7 @@ function cons(a, l) { } function hd(param) { - if (param) { + if (param !== 0) { return param.hd; } else { return Pervasives.failwith("hd"); @@ -34,7 +34,7 @@ function hd(param) { } function tl(param) { - if (param) { + if (param !== 0) { return param.tl; } else { return Pervasives.failwith("tl"); @@ -50,7 +50,7 @@ function nth(l, n) { while (true) { let n$1 = _n; let l$1 = _l; - if (!l$1) { + if (l$1 === 0) { return Pervasives.failwith("nth"); } if (n$1 === 0) { @@ -71,7 +71,7 @@ function nth_opt(l, n) { while (true) { let n$1 = _n; let l$1 = _l; - if (!l$1) { + if (l$1 === 0) { return; } if (n$1 === 0) { @@ -87,7 +87,7 @@ function rev_append(_l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return l2; } _l2 = { @@ -141,7 +141,7 @@ function init(len, f) { } function flatten(param) { - if (param) { + if (param !== 0) { return Pervasives.$at(param.hd, flatten(param.tl)); } else { return /* [] */0; @@ -149,7 +149,7 @@ function flatten(param) { } function map(f, param) { - if (!param) { + if (param === 0) { return /* [] */0; } let r = f(param.hd); @@ -160,7 +160,7 @@ function map(f, param) { } function mapi(i, f, param) { - if (!param) { + if (param === 0) { return /* [] */0; } let r = f(i, param.hd); @@ -180,7 +180,7 @@ function rev_map(f, l) { while (true) { let param = _param; let accu = _accu; - if (!param) { + if (param === 0) { return accu; } _param = param.tl; @@ -195,7 +195,7 @@ function rev_map(f, l) { function iter(f, _param) { while (true) { let param = _param; - if (!param) { + if (param === 0) { return; } f(param.hd); @@ -210,7 +210,7 @@ function iteri(f, l) { while (true) { let param = _param; let i = _i; - if (!param) { + if (param === 0) { return; } f(i, param.hd); @@ -224,7 +224,7 @@ function fold_left(f, _accu, _l) { while (true) { let l = _l; let accu = _accu; - if (!l) { + if (l === 0) { return accu; } _l = l.tl; @@ -234,7 +234,7 @@ function fold_left(f, _accu, _l) { } function fold_right(f, l, accu) { - if (l) { + if (l !== 0) { return f(l.hd, fold_right(f, l.tl, accu)); } else { return accu; @@ -242,14 +242,14 @@ function fold_right(f, l, accu) { } function map2(f, l1, l2) { - if (!l1) { - if (l2) { + if (l1 === 0) { + if (l2 !== 0) { return Pervasives.invalid_arg("List.map2"); } else { return /* [] */0; } } - if (!l2) { + if (l2 === 0) { return Pervasives.invalid_arg("List.map2"); } let r = f(l1.hd, l2.hd); @@ -267,14 +267,14 @@ function rev_map2(f, l1, l2) { let l2$1 = _l2; let l1$1 = _l1; let accu = _accu; - if (!l1$1) { - if (l2$1) { + if (l1$1 === 0) { + if (l2$1 !== 0) { return Pervasives.invalid_arg("List.rev_map2"); } else { return accu; } } - if (!l2$1) { + if (l2$1 === 0) { return Pervasives.invalid_arg("List.rev_map2"); } _l2 = l2$1.tl; @@ -291,14 +291,14 @@ function iter2(f, _l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { - if (l2) { + if (l1 === 0) { + if (l2 !== 0) { return Pervasives.invalid_arg("List.iter2"); } else { return; } } - if (!l2) { + if (l2 === 0) { return Pervasives.invalid_arg("List.iter2"); } f(l1.hd, l2.hd); @@ -313,14 +313,14 @@ function fold_left2(f, _accu, _l1, _l2) { let l2 = _l2; let l1 = _l1; let accu = _accu; - if (!l1) { - if (l2) { + if (l1 === 0) { + if (l2 !== 0) { return Pervasives.invalid_arg("List.fold_left2"); } else { return accu; } } - if (!l2) { + if (l2 === 0) { return Pervasives.invalid_arg("List.fold_left2"); } _l2 = l2.tl; @@ -331,13 +331,13 @@ function fold_left2(f, _accu, _l1, _l2) { } function fold_right2(f, l1, l2, accu) { - if (l1) { - if (l2) { + if (l1 !== 0) { + if (l2 !== 0) { return f(l1.hd, l2.hd, fold_right2(f, l1.tl, l2.tl, accu)); } else { return Pervasives.invalid_arg("List.fold_right2"); } - } else if (l2) { + } else if (l2 !== 0) { return Pervasives.invalid_arg("List.fold_right2"); } else { return accu; @@ -347,7 +347,7 @@ function fold_right2(f, l1, l2, accu) { function for_all(p, _param) { while (true) { let param = _param; - if (!param) { + if (param === 0) { return true; } if (!p(param.hd)) { @@ -361,7 +361,7 @@ function for_all(p, _param) { function exists(p, _param) { while (true) { let param = _param; - if (!param) { + if (param === 0) { return false; } if (p(param.hd)) { @@ -376,14 +376,14 @@ function for_all2(p, _l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { - if (l2) { + if (l1 === 0) { + if (l2 !== 0) { return Pervasives.invalid_arg("List.for_all2"); } else { return true; } } - if (!l2) { + if (l2 === 0) { return Pervasives.invalid_arg("List.for_all2"); } if (!p(l1.hd, l2.hd)) { @@ -399,14 +399,14 @@ function exists2(p, _l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { - if (l2) { + if (l1 === 0) { + if (l2 !== 0) { return Pervasives.invalid_arg("List.exists2"); } else { return false; } } - if (!l2) { + if (l2 === 0) { return Pervasives.invalid_arg("List.exists2"); } if (p(l1.hd, l2.hd)) { @@ -421,7 +421,7 @@ function exists2(p, _l1, _l2) { function mem(x, _param) { while (true) { let param = _param; - if (!param) { + if (param === 0) { return false; } if (param.hd === x) { @@ -435,7 +435,7 @@ function mem(x, _param) { function memq(x, _param) { while (true) { let param = _param; - if (!param) { + if (param === 0) { return false; } if (param.hd === x) { @@ -449,7 +449,7 @@ function memq(x, _param) { function assoc(x, _param) { while (true) { let param = _param; - if (param) { + if (param !== 0) { let match = param.hd; if (match[0] === x) { return match[1]; @@ -467,7 +467,7 @@ function assoc(x, _param) { function assoc_opt(x, _param) { while (true) { let param = _param; - if (!param) { + if (param === 0) { return; } let match = param.hd; @@ -482,7 +482,7 @@ function assoc_opt(x, _param) { function assq(x, _param) { while (true) { let param = _param; - if (param) { + if (param !== 0) { let match = param.hd; if (match[0] === x) { return match[1]; @@ -500,7 +500,7 @@ function assq(x, _param) { function assq_opt(x, _param) { while (true) { let param = _param; - if (!param) { + if (param === 0) { return; } let match = param.hd; @@ -515,7 +515,7 @@ function assq_opt(x, _param) { function mem_assoc(x, _param) { while (true) { let param = _param; - if (!param) { + if (param === 0) { return false; } if (param.hd[0] === x) { @@ -529,7 +529,7 @@ function mem_assoc(x, _param) { function mem_assq(x, _param) { while (true) { let param = _param; - if (!param) { + if (param === 0) { return false; } if (param.hd[0] === x) { @@ -541,7 +541,7 @@ function mem_assq(x, _param) { } function remove_assoc(x, param) { - if (!param) { + if (param === 0) { return /* [] */0; } let l = param.tl; @@ -557,7 +557,7 @@ function remove_assoc(x, param) { } function remove_assq(x, param) { - if (!param) { + if (param === 0) { return /* [] */0; } let l = param.tl; @@ -575,7 +575,7 @@ function remove_assq(x, param) { function find(p, _param) { while (true) { let param = _param; - if (param) { + if (param !== 0) { let x = param.hd; if (p(x)) { return x; @@ -593,7 +593,7 @@ function find(p, _param) { function find_opt(p, _param) { while (true) { let param = _param; - if (!param) { + if (param === 0) { return; } let x = param.hd; @@ -611,7 +611,7 @@ function find_all(p, l) { while (true) { let param = _param; let accu = _accu; - if (!param) { + if (param === 0) { return rev_append(accu, /* [] */0); } let l$1 = param.tl; @@ -637,7 +637,7 @@ function partition(p, l) { let param = _param; let no = _no; let yes = _yes; - if (!param) { + if (param === 0) { return [ rev_append(yes, /* [] */0), rev_append(no, /* [] */0) @@ -663,7 +663,7 @@ function partition(p, l) { } function split(param) { - if (!param) { + if (param === 0) { return [ /* [] */0, /* [] */0 @@ -684,8 +684,8 @@ function split(param) { } function combine(l1, l2) { - if (l1) { - if (l2) { + if (l1 !== 0) { + if (l2 !== 0) { return { hd: [ l1.hd, @@ -696,7 +696,7 @@ function combine(l1, l2) { } else { return Pervasives.invalid_arg("List.combine"); } - } else if (l2) { + } else if (l2 !== 0) { return Pervasives.invalid_arg("List.combine"); } else { return /* [] */0; @@ -704,10 +704,10 @@ function combine(l1, l2) { } function merge(cmp, l1, l2) { - if (!l1) { + if (l1 === 0) { return l2; } - if (!l2) { + if (l2 === 0) { return l1; } let h2 = l2.hd; @@ -732,7 +732,7 @@ function chop(_k, _l) { if (k === 0) { return l; } - if (l) { + if (l !== 0) { _l = l.tl; _k = k - 1 | 0; continue; @@ -752,11 +752,11 @@ function chop(_k, _l) { function stable_sort(cmp, l) { let sort = (n, l) => { if (n !== 2) { - if (n === 3 && l) { + if (n === 3 && l !== 0) { let match = l.tl; - if (match) { + if (match !== 0) { let match$1 = match.tl; - if (match$1) { + if (match$1 !== 0) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; @@ -835,9 +835,9 @@ function stable_sort(cmp, l) { } - } else if (l) { + } else if (l !== 0) { let match$2 = l.tl; - if (match$2) { + if (match$2 !== 0) { let x2$1 = match$2.hd; let x1$1 = l.hd; if (cmp(x1$1, x2$1) <= 0) { @@ -872,10 +872,10 @@ function stable_sort(cmp, l) { let accu = _accu; let l2$1 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return rev_append(l2$1, accu); } - if (!l2$1) { + if (l2$1 === 0) { return rev_append(l1, accu); } let h2 = l2$1.hd; @@ -898,11 +898,11 @@ function stable_sort(cmp, l) { }; let rev_sort = (n, l) => { if (n !== 2) { - if (n === 3 && l) { + if (n === 3 && l !== 0) { let match = l.tl; - if (match) { + if (match !== 0) { let match$1 = match.tl; - if (match$1) { + if (match$1 !== 0) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; @@ -981,9 +981,9 @@ function stable_sort(cmp, l) { } - } else if (l) { + } else if (l !== 0) { let match$2 = l.tl; - if (match$2) { + if (match$2 !== 0) { let x2$1 = match$2.hd; let x1$1 = l.hd; if (cmp(x1$1, x2$1) > 0) { @@ -1018,10 +1018,10 @@ function stable_sort(cmp, l) { let accu = _accu; let l2$1 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return rev_append(l2$1, accu); } - if (!l2$1) { + if (l2$1 === 0) { return rev_append(l1, accu); } let h2 = l2$1.hd; @@ -1053,11 +1053,11 @@ function stable_sort(cmp, l) { function sort_uniq(cmp, l) { let sort = (n, l) => { if (n !== 2) { - if (n === 3 && l) { + if (n === 3 && l !== 0) { let match = l.tl; - if (match) { + if (match !== 0) { let match$1 = match.tl; - if (match$1) { + if (match$1 !== 0) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; @@ -1203,9 +1203,9 @@ function sort_uniq(cmp, l) { } - } else if (l) { + } else if (l !== 0) { let match$2 = l.tl; - if (match$2) { + if (match$2 !== 0) { let x2$1 = match$2.hd; let x1$1 = l.hd; let c$6 = cmp(x1$1, x2$1); @@ -1246,10 +1246,10 @@ function sort_uniq(cmp, l) { let accu = _accu; let l2$1 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return rev_append(l2$1, accu); } - if (!l2$1) { + if (l2$1 === 0) { return rev_append(l1, accu); } let t2 = l2$1.tl; @@ -1284,11 +1284,11 @@ function sort_uniq(cmp, l) { }; let rev_sort = (n, l) => { if (n !== 2) { - if (n === 3 && l) { + if (n === 3 && l !== 0) { let match = l.tl; - if (match) { + if (match !== 0) { let match$1 = match.tl; - if (match$1) { + if (match$1 !== 0) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; @@ -1434,9 +1434,9 @@ function sort_uniq(cmp, l) { } - } else if (l) { + } else if (l !== 0) { let match$2 = l.tl; - if (match$2) { + if (match$2 !== 0) { let x2$1 = match$2.hd; let x1$1 = l.hd; let c$6 = cmp(x1$1, x2$1); @@ -1477,10 +1477,10 @@ function sort_uniq(cmp, l) { let accu = _accu; let l2$1 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return rev_append(l2$1, accu); } - if (!l2$1) { + if (l2$1 === 0) { return rev_append(l1, accu); } let t2 = l2$1.tl; @@ -1525,14 +1525,14 @@ function compare_lengths(_l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { - if (l2) { + if (l1 === 0) { + if (l2 !== 0) { return -1; } else { return 0; } } - if (!l2) { + if (l2 === 0) { return 1; } _l2 = l2.tl; @@ -1545,7 +1545,7 @@ function compare_length_with(_l, _n) { while (true) { let n = _n; let l = _l; - if (!l) { + if (l === 0) { if (n === 0) { return 0; } else if (n > 0) { diff --git a/tests/tests/src/polymorphism_test.mjs b/tests/tests/src/polymorphism_test.mjs index 8acb18b56a..ba38b2d850 100644 --- a/tests/tests/src/polymorphism_test.mjs +++ b/tests/tests/src/polymorphism_test.mjs @@ -2,7 +2,7 @@ function map(f, x) { - if (!x) { + if (x === 0) { return /* [] */0; } let r = f(x.hd); diff --git a/tests/tests/src/reasonReactRouter.mjs b/tests/tests/src/reasonReactRouter.mjs index 92c3a7013b..1e22e6d9b2 100644 --- a/tests/tests/src/reasonReactRouter.mjs +++ b/tests/tests/src/reasonReactRouter.mjs @@ -107,10 +107,10 @@ function urlNotEqual(a, b) { while (true) { let bList = _bList; let aList = _aList; - if (!aList) { - return bList; + if (aList === 0) { + return bList !== 0; } - if (!bList) { + if (bList === 0) { return true; } if (aList.hd !== bList.hd) { diff --git a/tests/tests/src/set_gen.mjs b/tests/tests/src/set_gen.mjs index c295c5829d..19fb820753 100644 --- a/tests/tests/src/set_gen.mjs +++ b/tests/tests/src/set_gen.mjs @@ -438,7 +438,7 @@ function of_sorted_list(l) { l ]; case 1 : - if (l) { + if (l !== 0) { return [ { TAG: "Node", @@ -452,9 +452,9 @@ function of_sorted_list(l) { } break; case 2 : - if (l) { + if (l !== 0) { let match = l.tl; - if (match) { + if (match !== 0) { return [ { TAG: "Node", @@ -476,11 +476,11 @@ function of_sorted_list(l) { } break; case 3 : - if (l) { + if (l !== 0) { let match$1 = l.tl; - if (match$1) { + if (match$1 !== 0) { let match$2 = match$1.tl; - if (match$2) { + if (match$2 !== 0) { return [ { TAG: "Node", @@ -513,7 +513,7 @@ function of_sorted_list(l) { let nl = n / 2 | 0; let match$3 = sub(nl, l); let l$1 = match$3[1]; - if (l$1) { + if (l$1 !== 0) { let match$4 = sub((n - nl | 0) - 1 | 0, l$1.tl); return [ create(match$3[0], l$1.hd, match$4[0]), diff --git a/tests/tests/src/string_set.mjs b/tests/tests/src/string_set.mjs index e5ba524aef..c6d5a321c3 100644 --- a/tests/tests/src/string_set.mjs +++ b/tests/tests/src/string_set.mjs @@ -239,28 +239,28 @@ function find(x, _tree) { } function of_list(l) { - if (!l) { + if (l === 0) { return Set_gen.empty; } let match = l.tl; let x0 = l.hd; - if (!match) { + if (match === 0) { return Set_gen.singleton(x0); } let match$1 = match.tl; let x1 = match.hd; - if (!match$1) { + if (match$1 === 0) { return add(x1, Set_gen.singleton(x0)); } let match$2 = match$1.tl; let x2 = match$1.hd; - if (!match$2) { + if (match$2 === 0) { return add(x2, add(x1, Set_gen.singleton(x0))); } let match$3 = match$2.tl; let x3 = match$2.hd; - if (match$3) { - if (match$3.tl) { + if (match$3 !== 0) { + if (match$3.tl !== 0) { return Set_gen.of_sorted_list(Belt_List.sort(l, compare_elt)); } else { return add(match$3.hd, add(x3, add(x2, add(x1, Set_gen.singleton(x0))))); diff --git a/tests/tests/src/test_ari.mjs b/tests/tests/src/test_ari.mjs index a016c7a1c8..a36e53d1df 100644 --- a/tests/tests/src/test_ari.mjs +++ b/tests/tests/src/test_ari.mjs @@ -32,7 +32,7 @@ function length_aux(_len, _x) { while (true) { let x = _x; let len = _len; - if (!x) { + if (x === 0) { return len; } _x = x.tl; diff --git a/tests/tests/src/test_bool_equal.mjs b/tests/tests/src/test_bool_equal.mjs index d7e5c90a32..3bb876441f 100644 --- a/tests/tests/src/test_bool_equal.mjs +++ b/tests/tests/src/test_bool_equal.mjs @@ -98,7 +98,7 @@ function f4(x) { } function f5(x) { - if (x) { + if (x !== 0) { return 2; } else { return 1; diff --git a/tests/tests/src/test_list.mjs b/tests/tests/src/test_list.mjs index 524ef92d6e..ef5979b0a7 100644 --- a/tests/tests/src/test_list.mjs +++ b/tests/tests/src/test_list.mjs @@ -7,7 +7,7 @@ function length_aux(_len, _x) { while (true) { let x = _x; let len = _len; - if (!x) { + if (x === 0) { return len; } _x = x.tl; @@ -21,7 +21,7 @@ function length(l) { } function hd(x) { - if (x) { + if (x !== 0) { return x.hd; } else { return Pervasives.failwith("hd"); @@ -29,7 +29,7 @@ function hd(x) { } function tl(x) { - if (x) { + if (x !== 0) { return x.tl; } else { return Pervasives.failwith("tl"); @@ -45,7 +45,7 @@ function nth(l, n) { while (true) { let n$1 = _n; let l$1 = _l; - if (!l$1) { + if (l$1 === 0) { return Pervasives.failwith("nth"); } if (n$1 === 0) { @@ -61,7 +61,7 @@ function rev_append(_l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return l2; } _l2 = { @@ -78,7 +78,7 @@ function rev(l) { } function flatten(x) { - if (x) { + if (x !== 0) { return Pervasives.$at(x.hd, flatten(x.tl)); } else { return /* [] */0; @@ -86,7 +86,7 @@ function flatten(x) { } function map(f, x) { - if (!x) { + if (x === 0) { return /* [] */0; } let r = f(x.hd); @@ -97,7 +97,7 @@ function map(f, x) { } function mapi(i, f, x) { - if (!x) { + if (x === 0) { return /* [] */0; } let r = f(i, x.hd); @@ -117,7 +117,7 @@ function rev_map(f, l) { while (true) { let x = _x; let accu = _accu; - if (!x) { + if (x === 0) { return accu; } _x = x.tl; @@ -132,7 +132,7 @@ function rev_map(f, l) { function iter(f, _x) { while (true) { let x = _x; - if (!x) { + if (x === 0) { return; } f(x.hd); @@ -147,7 +147,7 @@ function iteri(f, l) { while (true) { let x = _x; let i = _i; - if (!x) { + if (x === 0) { return; } f(i, x.hd); @@ -161,7 +161,7 @@ function fold_left(f, _accu, _l) { while (true) { let l = _l; let accu = _accu; - if (!l) { + if (l === 0) { return accu; } _l = l.tl; @@ -171,7 +171,7 @@ function fold_left(f, _accu, _l) { } function fold_right(f, l, accu) { - if (l) { + if (l !== 0) { return f(l.hd, fold_right(f, l.tl, accu)); } else { return accu; @@ -179,14 +179,14 @@ function fold_right(f, l, accu) { } function map2(f, l1, l2) { - if (!l1) { - if (l2) { + if (l1 === 0) { + if (l2 !== 0) { return Pervasives.invalid_arg("List.map2"); } else { return /* [] */0; } } - if (!l2) { + if (l2 === 0) { return Pervasives.invalid_arg("List.map2"); } let r = f(l1.hd, l2.hd); @@ -204,14 +204,14 @@ function rev_map2(f, l1, l2) { let l2$1 = _l2; let l1$1 = _l1; let accu = _accu; - if (!l1$1) { - if (l2$1) { + if (l1$1 === 0) { + if (l2$1 !== 0) { return Pervasives.invalid_arg("List.rev_map2"); } else { return accu; } } - if (!l2$1) { + if (l2$1 === 0) { return Pervasives.invalid_arg("List.rev_map2"); } _l2 = l2$1.tl; @@ -228,14 +228,14 @@ function iter2(f, _l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { - if (l2) { + if (l1 === 0) { + if (l2 !== 0) { return Pervasives.invalid_arg("List.iter2"); } else { return; } } - if (!l2) { + if (l2 === 0) { return Pervasives.invalid_arg("List.iter2"); } f(l1.hd, l2.hd); @@ -250,14 +250,14 @@ function fold_left2(f, _accu, _l1, _l2) { let l2 = _l2; let l1 = _l1; let accu = _accu; - if (!l1) { - if (l2) { + if (l1 === 0) { + if (l2 !== 0) { return Pervasives.invalid_arg("List.fold_left2"); } else { return accu; } } - if (!l2) { + if (l2 === 0) { return Pervasives.invalid_arg("List.fold_left2"); } _l2 = l2.tl; @@ -268,13 +268,13 @@ function fold_left2(f, _accu, _l1, _l2) { } function fold_right2(f, l1, l2, accu) { - if (l1) { - if (l2) { + if (l1 !== 0) { + if (l2 !== 0) { return f(l1.hd, l2.hd, fold_right2(f, l1.tl, l2.tl, accu)); } else { return Pervasives.invalid_arg("List.fold_right2"); } - } else if (l2) { + } else if (l2 !== 0) { return Pervasives.invalid_arg("List.fold_right2"); } else { return accu; @@ -284,7 +284,7 @@ function fold_right2(f, l1, l2, accu) { function for_all(p, _x) { while (true) { let x = _x; - if (!x) { + if (x === 0) { return true; } if (!p(x.hd)) { @@ -298,7 +298,7 @@ function for_all(p, _x) { function exists(p, _x) { while (true) { let x = _x; - if (!x) { + if (x === 0) { return false; } if (p(x.hd)) { @@ -313,14 +313,14 @@ function for_all2(p, _l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { - if (l2) { + if (l1 === 0) { + if (l2 !== 0) { return Pervasives.invalid_arg("List.for_all2"); } else { return true; } } - if (!l2) { + if (l2 === 0) { return Pervasives.invalid_arg("List.for_all2"); } if (!p(l1.hd, l2.hd)) { @@ -336,14 +336,14 @@ function exists2(p, _l1, _l2) { while (true) { let l2 = _l2; let l1 = _l1; - if (!l1) { - if (l2) { + if (l1 === 0) { + if (l2 !== 0) { return Pervasives.invalid_arg("List.exists2"); } else { return false; } } - if (!l2) { + if (l2 === 0) { return Pervasives.invalid_arg("List.exists2"); } if (p(l1.hd, l2.hd)) { @@ -358,7 +358,7 @@ function exists2(p, _l1, _l2) { function mem(x, _x_) { while (true) { let x_ = _x_; - if (!x_) { + if (x_ === 0) { return false; } if (x_.hd === x) { @@ -372,7 +372,7 @@ function mem(x, _x_) { function memq(x, _x_) { while (true) { let x_ = _x_; - if (!x_) { + if (x_ === 0) { return false; } if (x_.hd === x) { @@ -386,7 +386,7 @@ function memq(x, _x_) { function assoc(x, _x_) { while (true) { let x_ = _x_; - if (x_) { + if (x_ !== 0) { let match = x_.hd; if (match[0] === x) { return match[1]; @@ -404,7 +404,7 @@ function assoc(x, _x_) { function assq(x, _x_) { while (true) { let x_ = _x_; - if (x_) { + if (x_ !== 0) { let match = x_.hd; if (match[0] === x) { return match[1]; @@ -422,7 +422,7 @@ function assq(x, _x_) { function mem_assoc(x, _x_) { while (true) { let x_ = _x_; - if (!x_) { + if (x_ === 0) { return false; } if (x_.hd[0] === x) { @@ -436,7 +436,7 @@ function mem_assoc(x, _x_) { function mem_assq(x, _x_) { while (true) { let x_ = _x_; - if (!x_) { + if (x_ === 0) { return false; } if (x_.hd[0] === x) { @@ -448,7 +448,7 @@ function mem_assq(x, _x_) { } function remove_assoc(x, x_) { - if (!x_) { + if (x_ === 0) { return /* [] */0; } let l = x_.tl; @@ -464,7 +464,7 @@ function remove_assoc(x, x_) { } function remove_assq(x, x_) { - if (!x_) { + if (x_ === 0) { return /* [] */0; } let l = x_.tl; @@ -482,7 +482,7 @@ function remove_assq(x, x_) { function find(p, _x) { while (true) { let x = _x; - if (x) { + if (x !== 0) { let x$1 = x.hd; if (p(x$1)) { return x$1; @@ -504,7 +504,7 @@ function find_all(p) { while (true) { let x = _x; let accu = _accu; - if (!x) { + if (x === 0) { return rev_append(accu, /* [] */0); } let l = x.tl; @@ -531,7 +531,7 @@ function partition(p, l) { let x = _x; let no = _no; let yes = _yes; - if (!x) { + if (x === 0) { return [ rev_append(yes, /* [] */0), rev_append(no, /* [] */0) @@ -557,7 +557,7 @@ function partition(p, l) { } function split(x) { - if (!x) { + if (x === 0) { return [ /* [] */0, /* [] */0 @@ -578,8 +578,8 @@ function split(x) { } function combine(l1, l2) { - if (l1) { - if (l2) { + if (l1 !== 0) { + if (l2 !== 0) { return { hd: [ l1.hd, @@ -590,7 +590,7 @@ function combine(l1, l2) { } else { return Pervasives.invalid_arg("List.combine"); } - } else if (l2) { + } else if (l2 !== 0) { return Pervasives.invalid_arg("List.combine"); } else { return /* [] */0; @@ -598,10 +598,10 @@ function combine(l1, l2) { } function merge(cmp, l1, l2) { - if (!l1) { + if (l1 === 0) { return l2; } - if (!l2) { + if (l2 === 0) { return l1; } let h2 = l2.hd; @@ -626,7 +626,7 @@ function chop(_k, _l) { if (k === 0) { return l; } - if (l) { + if (l !== 0) { _l = l.tl; _k = k - 1 | 0; continue; @@ -646,11 +646,11 @@ function chop(_k, _l) { function stable_sort(cmp, l) { let sort = (n, l) => { if (n !== 2) { - if (n === 3 && l) { + if (n === 3 && l !== 0) { let match = l.tl; - if (match) { + if (match !== 0) { let match$1 = match.tl; - if (match$1) { + if (match$1 !== 0) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; @@ -729,9 +729,9 @@ function stable_sort(cmp, l) { } - } else if (l) { + } else if (l !== 0) { let match$2 = l.tl; - if (match$2) { + if (match$2 !== 0) { let x2$1 = match$2.hd; let x1$1 = l.hd; if (cmp(x1$1, x2$1) <= 0) { @@ -766,10 +766,10 @@ function stable_sort(cmp, l) { let accu = _accu; let l2$1 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return rev_append(l2$1, accu); } - if (!l2$1) { + if (l2$1 === 0) { return rev_append(l1, accu); } let h2 = l2$1.hd; @@ -792,11 +792,11 @@ function stable_sort(cmp, l) { }; let rev_sort = (n, l) => { if (n !== 2) { - if (n === 3 && l) { + if (n === 3 && l !== 0) { let match = l.tl; - if (match) { + if (match !== 0) { let match$1 = match.tl; - if (match$1) { + if (match$1 !== 0) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; @@ -875,9 +875,9 @@ function stable_sort(cmp, l) { } - } else if (l) { + } else if (l !== 0) { let match$2 = l.tl; - if (match$2) { + if (match$2 !== 0) { let x2$1 = match$2.hd; let x1$1 = l.hd; if (cmp(x1$1, x2$1) > 0) { @@ -912,10 +912,10 @@ function stable_sort(cmp, l) { let accu = _accu; let l2$1 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return rev_append(l2$1, accu); } - if (!l2$1) { + if (l2$1 === 0) { return rev_append(l1, accu); } let h2 = l2$1.hd; @@ -947,11 +947,11 @@ function stable_sort(cmp, l) { function sort_uniq(cmp, l) { let sort = (n, l) => { if (n !== 2) { - if (n === 3 && l) { + if (n === 3 && l !== 0) { let match = l.tl; - if (match) { + if (match !== 0) { let match$1 = match.tl; - if (match$1) { + if (match$1 !== 0) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; @@ -1097,9 +1097,9 @@ function sort_uniq(cmp, l) { } - } else if (l) { + } else if (l !== 0) { let match$2 = l.tl; - if (match$2) { + if (match$2 !== 0) { let x2$1 = match$2.hd; let x1$1 = l.hd; let c$6 = cmp(x1$1, x2$1); @@ -1140,10 +1140,10 @@ function sort_uniq(cmp, l) { let accu = _accu; let l2$1 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return rev_append(l2$1, accu); } - if (!l2$1) { + if (l2$1 === 0) { return rev_append(l1, accu); } let t2 = l2$1.tl; @@ -1178,11 +1178,11 @@ function sort_uniq(cmp, l) { }; let rev_sort = (n, l) => { if (n !== 2) { - if (n === 3 && l) { + if (n === 3 && l !== 0) { let match = l.tl; - if (match) { + if (match !== 0) { let match$1 = match.tl; - if (match$1) { + if (match$1 !== 0) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; @@ -1328,9 +1328,9 @@ function sort_uniq(cmp, l) { } - } else if (l) { + } else if (l !== 0) { let match$2 = l.tl; - if (match$2) { + if (match$2 !== 0) { let x2$1 = match$2.hd; let x1$1 = l.hd; let c$6 = cmp(x1$1, x2$1); @@ -1371,10 +1371,10 @@ function sort_uniq(cmp, l) { let accu = _accu; let l2$1 = _l2; let l1 = _l1; - if (!l1) { + if (l1 === 0) { return rev_append(l2$1, accu); } - if (!l2$1) { + if (l2$1 === 0) { return rev_append(l1, accu); } let t2 = l2$1.tl; @@ -1415,6 +1415,14 @@ function sort_uniq(cmp, l) { } } +function isEmpty(x) { + return x === 0; +} + +function isEmpty2(x) { + return x === /* [] */0; +} + let u = Belt_List.length; let append = Pervasives.$at; @@ -1475,5 +1483,7 @@ export { sort, fast_sort, sort_uniq, + isEmpty, + isEmpty2, } /* No side effect */ diff --git a/tests/tests/src/test_list.res b/tests/tests/src/test_list.res index 915566e571..44b9db0ac1 100644 --- a/tests/tests/src/test_list.res +++ b/tests/tests/src/test_list.res @@ -612,3 +612,11 @@ let sort_uniq = (cmp, l) => { sort(len, l) } } + +let isEmpty = x => + switch x { + | list{} => true + | _ => false + } + +let isEmpty2 = x => x == list{} ? true : false diff --git a/tests/tests/src/test_seq.mjs b/tests/tests/src/test_seq.mjs index b436695590..574bfbfdd9 100644 --- a/tests/tests/src/test_seq.mjs +++ b/tests/tests/src/test_seq.mjs @@ -13,7 +13,7 @@ let Stop = /* @__PURE__ */Primitive_exceptions.create("Test_seq.Stop"); function assoc3(x, _l) { while (true) { let l = _l; - if (l) { + if (l !== 0) { let match = l.hd; if (Primitive_object.equal(match[0], x)) { return match[1]; diff --git a/tests/tests/src/test_set.mjs b/tests/tests/src/test_set.mjs index 73fdff0f7c..7be82024e1 100644 --- a/tests/tests/src/test_set.mjs +++ b/tests/tests/src/test_set.mjs @@ -554,7 +554,7 @@ function Make(Ord) { l ]; case 1 : - if (l) { + if (l !== 0) { return [ { TAG: "Node", @@ -568,9 +568,9 @@ function Make(Ord) { } break; case 2 : - if (l) { + if (l !== 0) { let match = l.tl; - if (match) { + if (match !== 0) { return [ { TAG: "Node", @@ -592,11 +592,11 @@ function Make(Ord) { } break; case 3 : - if (l) { + if (l !== 0) { let match$1 = l.tl; - if (match$1) { + if (match$1 !== 0) { let match$2 = match$1.tl; - if (match$2) { + if (match$2 !== 0) { return [ { TAG: "Node", @@ -629,7 +629,7 @@ function Make(Ord) { let nl = n / 2 | 0; let match$3 = sub(nl, l); let l$1 = match$3[1]; - if (l$1) { + if (l$1 !== 0) { let match$4 = sub((n - nl | 0) - 1 | 0, l$1.tl); return [ create(match$3[0], l$1.hd, match$4[0]), @@ -649,28 +649,28 @@ function Make(Ord) { return sub(Belt_List.length(l), l)[0]; }; let of_list = l => { - if (!l) { + if (l === 0) { return "Empty"; } let match = l.tl; let x0 = l.hd; - if (!match) { + if (match === 0) { return singleton(x0); } let match$1 = match.tl; let x1 = match.hd; - if (!match$1) { + if (match$1 === 0) { return add(x1, singleton(x0)); } let match$2 = match$1.tl; let x2 = match$1.hd; - if (!match$2) { + if (match$2 === 0) { return add(x2, add(x1, singleton(x0))); } let match$3 = match$2.tl; let x3 = match$2.hd; - if (match$3) { - if (match$3.tl) { + if (match$3 !== 0) { + if (match$3.tl !== 0) { return of_sorted_list(Belt_List.sort(l, Ord.compare)); } else { return add(match$3.hd, add(x3, add(x2, add(x1, singleton(x0))))); diff --git a/tests/tests/src/test_simple_tailcall.mjs b/tests/tests/src/test_simple_tailcall.mjs index 48ae85ce9c..180ee03a16 100644 --- a/tests/tests/src/test_simple_tailcall.mjs +++ b/tests/tests/src/test_simple_tailcall.mjs @@ -8,7 +8,7 @@ function tailcall(x) { } function non_length(x) { - if (x) { + if (x !== 0) { return 1 + non_length(x.tl) | 0; } else { return 0; @@ -19,11 +19,11 @@ function length(_acc, _x) { while (true) { let x = _x; let acc = _acc; - if (!x) { + if (x === 0) { return acc; } let tl = x.tl; - if (tl) { + if (tl !== 0) { return 1 + length(acc + 1 | 0, tl.tl) | 0; } _x = tl; diff --git a/tests/tests/src/ticker.mjs b/tests/tests/src/ticker.mjs index a4eca36b56..aa5dd34648 100644 --- a/tests/tests/src/ticker.mjs +++ b/tests/tests/src/ticker.mjs @@ -208,20 +208,20 @@ function process_input_line(ticker_map, all_tickers, line) { }; }; let tokens = split("|", line); - if (!tokens) { + if (tokens === 0) { return Pervasives.failwith("Invalid input line"); } switch (tokens.hd) { case "Q" : let match = tokens.tl; - if (!match) { + if (match === 0) { return Pervasives.failwith("Invalid input line"); } let match$1 = match.tl; - if (!match$1) { + if (match$1 === 0) { return Pervasives.failwith("Invalid input line"); } - if (match$1.tl) { + if (match$1.tl !== 0) { return Pervasives.failwith("Invalid input line"); } let ticker_map$1 = ticker_map !== undefined ? Primitive_option.valFromOption(ticker_map) : compute_update_sequences(all_tickers); @@ -233,22 +233,22 @@ function process_input_line(ticker_map, all_tickers, line) { ]; case "R" : let match$2 = tokens.tl; - if (!match$2) { + if (match$2 === 0) { return Pervasives.failwith("Invalid input line"); } let match$3 = match$2.tl; - if (!match$3) { + if (match$3 === 0) { return Pervasives.failwith("Invalid input line"); } let ticker_name = match$2.hd; switch (match$3.hd) { case "+" : let match$4 = match$3.tl; - if (!match$4) { + if (match$4 === 0) { return Pervasives.failwith("Invalid input line"); } let match$5 = match$4.tl; - if (match$5 && !match$5.tl) { + if (match$5 !== 0 && match$5.tl === 0) { return [ { hd: make_binary_op(ticker_name, match$4.hd, match$5.hd, "PLUS"), @@ -261,11 +261,11 @@ function process_input_line(ticker_map, all_tickers, line) { } case "-" : let match$6 = match$3.tl; - if (!match$6) { + if (match$6 === 0) { return Pervasives.failwith("Invalid input line"); } let match$7 = match$6.tl; - if (match$7 && !match$7.tl) { + if (match$7 !== 0 && match$7.tl === 0) { return [ { hd: make_binary_op(ticker_name, match$6.hd, match$7.hd, "MINUS"), @@ -277,7 +277,7 @@ function process_input_line(ticker_map, all_tickers, line) { return Pervasives.failwith("Invalid input line"); } case "S" : - if (match$3.tl) { + if (match$3.tl !== 0) { return Pervasives.failwith("Invalid input line"); } else { return [ @@ -306,7 +306,7 @@ function loop(_lines, _param) { let param = _param; let lines = _lines; let all_tickers = param[0]; - if (!lines) { + if (lines === 0) { return print_all_composite(all_tickers); } _param = process_input_line(param[1], all_tickers, lines.hd); diff --git a/tests/tests/src/topsort_test.mjs b/tests/tests/src/topsort_test.mjs index 2dc512b66a..017e284e7c 100644 --- a/tests/tests/src/topsort_test.mjs +++ b/tests/tests/src/topsort_test.mjs @@ -73,7 +73,7 @@ function dfs1(_nodes, graph, _visited) { while (true) { let visited = _visited; let nodes = _nodes; - if (!nodes) { + if (nodes === 0) { return Belt_List.reverse(visited); } let xs = nodes.tl; @@ -171,7 +171,7 @@ function dfs2(nodes, graph, visited) { while (true) { let visited = _visited; let nodes = _nodes; - if (!nodes) { + if (nodes === 0) { return visited; } let xs = nodes.tl; @@ -539,13 +539,13 @@ try { let exit = 0; if (exn.RE_EXN_ID === Cycle) { let match = exn._1; - if (match && match.hd === "go") { + if (match !== 0 && match.hd === "go") { let match$1 = match.tl; - if (match$1 && match$1.hd === "washup") { + if (match$1 !== 0 && match$1.hd === "washup") { let match$2 = match$1.tl; - if (match$2 && match$2.hd === "eat") { + if (match$2 !== 0 && match$2.hd === "eat") { let match$3 = match$2.tl; - if (!(match$3 && !(match$3.hd !== "go" || match$3.tl))) { + if (match$3 === 0 || match$3.hd !== "go" || match$3.tl !== 0) { exit = 1; } diff --git a/tests/tests/src/variantsMatching.mjs b/tests/tests/src/variantsMatching.mjs index 4e367a3740..0ee83a8320 100644 --- a/tests/tests/src/variantsMatching.mjs +++ b/tests/tests/src/variantsMatching.mjs @@ -82,22 +82,22 @@ function showToJs(x) { } function third(l) { - if (!l) { + if (l === 0) { return false; } if (l.hd !== 1) { return false; } let match = l.tl; - if (!match) { + if (match === 0) { return false; } if (match.hd !== 2) { return false; } let match$1 = match.tl; - if (match$1 && match$1.hd === 3) { - return !match$1.tl; + if (match$1 !== 0 && match$1.hd === 3) { + return match$1.tl === 0; } else { return false; }