Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 31ab245

Browse files
committedApr 14, 2025··
Revert "unparen shift ops"
This reverts commit 5d308e7.
1 parent 5d308e7 commit 31ab245

37 files changed

+117
-105
lines changed
 

‎compiler/core/js_dump.ml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,13 @@ and expression_desc cxt ~(level : int) f x : cxt =
717717
expression_desc cxt ~level:(level : int) f (Is_null_or_undefined e1)
718718
| Bin (op, e1, e2) ->
719719
let out, lft, rght = Js_op_util.op_prec op in
720-
let need_paren = level > out in
720+
let need_paren =
721+
level > out
722+
||
723+
match op with
724+
| Lsl | Lsr | Asr -> true
725+
| _ -> false
726+
in
721727
(* We are more conservative here, to make the generated code more readable
722728
to the user *)
723729
P.cond_paren_group f need_paren (fun _ ->
@@ -729,7 +735,13 @@ and expression_desc cxt ~(level : int) f x : cxt =
729735
| String_append (e1, e2) ->
730736
let op : Js_op.binop = Plus in
731737
let out, lft, rght = Js_op_util.op_prec op in
732-
let need_paren = level > out in
738+
let need_paren =
739+
level > out
740+
||
741+
match op with
742+
| Lsl | Lsr | Asr -> true
743+
| _ -> false
744+
in
733745
P.cond_paren_group f need_paren (fun _ ->
734746
let cxt = expression ~level:lft cxt f e1 in
735747
P.space f;

‎lib/es6/Belt_HashMap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ function set0(h, key, value, eq, hash) {
6666
};
6767
h.size = h.size + 1 | 0;
6868
}
69-
if (h.size > buckets_len << 1) {
69+
if (h.size > (buckets_len << 1)) {
7070
let odata = h.buckets;
7171
let osize = odata.length;
72-
let nsize = osize << 1;
72+
let nsize = (osize << 1);
7373
if (nsize < osize) {
7474
return;
7575
}

‎lib/es6/Belt_HashMapInt.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ function set(h, key, value) {
6363
};
6464
h.size = h.size + 1 | 0;
6565
}
66-
if (h.size > buckets_len << 1) {
66+
if (h.size > (buckets_len << 1)) {
6767
let odata = h.buckets;
6868
let osize = odata.length;
69-
let nsize = osize << 1;
69+
let nsize = (osize << 1);
7070
if (nsize < osize) {
7171
return;
7272
}

‎lib/es6/Belt_HashMapString.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ function set(h, key, value) {
6363
};
6464
h.size = h.size + 1 | 0;
6565
}
66-
if (h.size > buckets_len << 1) {
66+
if (h.size > (buckets_len << 1)) {
6767
let odata = h.buckets;
6868
let osize = odata.length;
69-
let nsize = osize << 1;
69+
let nsize = (osize << 1);
7070
if (nsize < osize) {
7171
return;
7272
}

‎lib/es6/Belt_HashSet.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ function add0(h, key, hash, eq) {
9393
next: undefined
9494
};
9595
}
96-
if (h.size > buckets_len << 1) {
96+
if (h.size > (buckets_len << 1)) {
9797
let odata = h.buckets;
9898
let osize = odata.length;
99-
let nsize = osize << 1;
99+
let nsize = (osize << 1);
100100
if (nsize < osize) {
101101
return;
102102
}

‎lib/es6/Belt_HashSetInt.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ function add(h, key) {
9393
};
9494
h.size = h.size + 1 | 0;
9595
}
96-
if (h.size > buckets_len << 1) {
96+
if (h.size > (buckets_len << 1)) {
9797
let odata = h.buckets;
9898
let osize = odata.length;
99-
let nsize = osize << 1;
99+
let nsize = (osize << 1);
100100
if (nsize < osize) {
101101
return;
102102
}

‎lib/es6/Belt_HashSetString.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ function add(h, key) {
9393
};
9494
h.size = h.size + 1 | 0;
9595
}
96-
if (h.size > buckets_len << 1) {
96+
if (h.size > (buckets_len << 1)) {
9797
let odata = h.buckets;
9898
let osize = odata.length;
99-
let nsize = osize << 1;
99+
let nsize = (osize << 1);
100100
if (nsize < osize) {
101101
return;
102102
}

‎lib/es6/Belt_internalBucketsType.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ function power_2_above(_x, n) {
77
if (x >= n) {
88
return x;
99
}
10-
if (x << 1 < x) {
10+
if ((x << 1) < x) {
1111
return x;
1212
}
13-
_x = x << 1;
13+
_x = (x << 1);
1414
continue;
1515
};
1616
}

‎lib/es6/Primitive_hash.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function unsafe_pop(q) {
4444
}
4545

4646
function rotl32(x, n) {
47-
return x << n | x >>> (32 - n | 0) | 0;
47+
return (x << n) | (x >>> (32 - n | 0)) | 0;
4848
}
4949

5050
function hash_mix_int(h, d) {
@@ -58,26 +58,26 @@ function hash_mix_int(h, d) {
5858
}
5959

6060
function hash_final_mix(h) {
61-
let h$1 = h ^ h >>> 16;
61+
let h$1 = h ^ (h >>> 16);
6262
h$1 = Math.imul(h$1, -2048144789);
63-
h$1 = h$1 ^ h$1 >>> 13;
63+
h$1 = h$1 ^ (h$1 >>> 13);
6464
h$1 = Math.imul(h$1, -1028477387);
65-
return h$1 ^ h$1 >>> 16;
65+
return h$1 ^ (h$1 >>> 16);
6666
}
6767

6868
function hash_mix_string(h, s) {
6969
let len = s.length;
7070
let block = (len / 4 | 0) - 1 | 0;
7171
let hash = h;
7272
for (let i = 0; i <= block; ++i) {
73-
let j = i << 2;
74-
let w = s.charCodeAt(j) | s.charCodeAt(j + 1 | 0) << 8 | s.charCodeAt(j + 2 | 0) << 16 | s.charCodeAt(j + 3 | 0) << 24;
73+
let j = (i << 2);
74+
let w = s.charCodeAt(j) | (s.charCodeAt(j + 1 | 0) << 8) | (s.charCodeAt(j + 2 | 0) << 16) | (s.charCodeAt(j + 3 | 0) << 24);
7575
hash = hash_mix_int(hash, w);
7676
}
7777
let modulo = len & 3;
7878
if (modulo !== 0) {
79-
let w$1 = modulo === 3 ? s.charCodeAt(len - 1 | 0) << 16 | s.charCodeAt(len - 2 | 0) << 8 | s.charCodeAt(len - 3 | 0) : (
80-
modulo === 2 ? s.charCodeAt(len - 1 | 0) << 8 | s.charCodeAt(len - 2 | 0) : s.charCodeAt(len - 1 | 0)
79+
let w$1 = modulo === 3 ? (s.charCodeAt(len - 1 | 0) << 16) | (s.charCodeAt(len - 2 | 0) << 8) | s.charCodeAt(len - 3 | 0) : (
80+
modulo === 2 ? (s.charCodeAt(len - 1 | 0) << 8) | s.charCodeAt(len - 2 | 0) : s.charCodeAt(len - 1 | 0)
8181
);
8282
hash = hash_mix_int(hash, w$1);
8383
}
@@ -117,7 +117,7 @@ function hash(count, _limit, seed, obj) {
117117
let size = obj$1.length | 0;
118118
if (size !== 0) {
119119
let obj_tag = obj$1.TAG;
120-
let tag = size << 10 | obj_tag;
120+
let tag = (size << 10) | obj_tag;
121121
s = hash_mix_int(s, tag);
122122
let v = size - 1 | 0;
123123
let block = v < num ? v : num;
@@ -133,7 +133,7 @@ function hash(count, _limit, seed, obj) {
133133
}
134134
return size
135135
})(obj$1, v => push_back(queue, v));
136-
s = hash_mix_int(s, size$1 << 10 | 0);
136+
s = hash_mix_int(s, (size$1 << 10) | 0);
137137
}
138138
}
139139

‎lib/js/Belt_HashMap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ function set0(h, key, value, eq, hash) {
6666
};
6767
h.size = h.size + 1 | 0;
6868
}
69-
if (h.size > buckets_len << 1) {
69+
if (h.size > (buckets_len << 1)) {
7070
let odata = h.buckets;
7171
let osize = odata.length;
72-
let nsize = osize << 1;
72+
let nsize = (osize << 1);
7373
if (nsize < osize) {
7474
return;
7575
}

‎lib/js/Belt_HashMapInt.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ function set(h, key, value) {
6363
};
6464
h.size = h.size + 1 | 0;
6565
}
66-
if (h.size > buckets_len << 1) {
66+
if (h.size > (buckets_len << 1)) {
6767
let odata = h.buckets;
6868
let osize = odata.length;
69-
let nsize = osize << 1;
69+
let nsize = (osize << 1);
7070
if (nsize < osize) {
7171
return;
7272
}

‎lib/js/Belt_HashMapString.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ function set(h, key, value) {
6363
};
6464
h.size = h.size + 1 | 0;
6565
}
66-
if (h.size > buckets_len << 1) {
66+
if (h.size > (buckets_len << 1)) {
6767
let odata = h.buckets;
6868
let osize = odata.length;
69-
let nsize = osize << 1;
69+
let nsize = (osize << 1);
7070
if (nsize < osize) {
7171
return;
7272
}

‎lib/js/Belt_HashSet.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ function add0(h, key, hash, eq) {
9393
next: undefined
9494
};
9595
}
96-
if (h.size > buckets_len << 1) {
96+
if (h.size > (buckets_len << 1)) {
9797
let odata = h.buckets;
9898
let osize = odata.length;
99-
let nsize = osize << 1;
99+
let nsize = (osize << 1);
100100
if (nsize < osize) {
101101
return;
102102
}

‎lib/js/Belt_HashSetInt.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ function add(h, key) {
9393
};
9494
h.size = h.size + 1 | 0;
9595
}
96-
if (h.size > buckets_len << 1) {
96+
if (h.size > (buckets_len << 1)) {
9797
let odata = h.buckets;
9898
let osize = odata.length;
99-
let nsize = osize << 1;
99+
let nsize = (osize << 1);
100100
if (nsize < osize) {
101101
return;
102102
}

‎lib/js/Belt_HashSetString.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ function add(h, key) {
9393
};
9494
h.size = h.size + 1 | 0;
9595
}
96-
if (h.size > buckets_len << 1) {
96+
if (h.size > (buckets_len << 1)) {
9797
let odata = h.buckets;
9898
let osize = odata.length;
99-
let nsize = osize << 1;
99+
let nsize = (osize << 1);
100100
if (nsize < osize) {
101101
return;
102102
}

‎lib/js/Belt_internalBucketsType.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ function power_2_above(_x, n) {
77
if (x >= n) {
88
return x;
99
}
10-
if (x << 1 < x) {
10+
if ((x << 1) < x) {
1111
return x;
1212
}
13-
_x = x << 1;
13+
_x = (x << 1);
1414
continue;
1515
};
1616
}

‎lib/js/Primitive_hash.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function unsafe_pop(q) {
4444
}
4545

4646
function rotl32(x, n) {
47-
return x << n | x >>> (32 - n | 0) | 0;
47+
return (x << n) | (x >>> (32 - n | 0)) | 0;
4848
}
4949

5050
function hash_mix_int(h, d) {
@@ -58,26 +58,26 @@ function hash_mix_int(h, d) {
5858
}
5959

6060
function hash_final_mix(h) {
61-
let h$1 = h ^ h >>> 16;
61+
let h$1 = h ^ (h >>> 16);
6262
h$1 = Math.imul(h$1, -2048144789);
63-
h$1 = h$1 ^ h$1 >>> 13;
63+
h$1 = h$1 ^ (h$1 >>> 13);
6464
h$1 = Math.imul(h$1, -1028477387);
65-
return h$1 ^ h$1 >>> 16;
65+
return h$1 ^ (h$1 >>> 16);
6666
}
6767

6868
function hash_mix_string(h, s) {
6969
let len = s.length;
7070
let block = (len / 4 | 0) - 1 | 0;
7171
let hash = h;
7272
for (let i = 0; i <= block; ++i) {
73-
let j = i << 2;
74-
let w = s.charCodeAt(j) | s.charCodeAt(j + 1 | 0) << 8 | s.charCodeAt(j + 2 | 0) << 16 | s.charCodeAt(j + 3 | 0) << 24;
73+
let j = (i << 2);
74+
let w = s.charCodeAt(j) | (s.charCodeAt(j + 1 | 0) << 8) | (s.charCodeAt(j + 2 | 0) << 16) | (s.charCodeAt(j + 3 | 0) << 24);
7575
hash = hash_mix_int(hash, w);
7676
}
7777
let modulo = len & 3;
7878
if (modulo !== 0) {
79-
let w$1 = modulo === 3 ? s.charCodeAt(len - 1 | 0) << 16 | s.charCodeAt(len - 2 | 0) << 8 | s.charCodeAt(len - 3 | 0) : (
80-
modulo === 2 ? s.charCodeAt(len - 1 | 0) << 8 | s.charCodeAt(len - 2 | 0) : s.charCodeAt(len - 1 | 0)
79+
let w$1 = modulo === 3 ? (s.charCodeAt(len - 1 | 0) << 16) | (s.charCodeAt(len - 2 | 0) << 8) | s.charCodeAt(len - 3 | 0) : (
80+
modulo === 2 ? (s.charCodeAt(len - 1 | 0) << 8) | s.charCodeAt(len - 2 | 0) : s.charCodeAt(len - 1 | 0)
8181
);
8282
hash = hash_mix_int(hash, w$1);
8383
}
@@ -117,7 +117,7 @@ function hash(count, _limit, seed, obj) {
117117
let size = obj$1.length | 0;
118118
if (size !== 0) {
119119
let obj_tag = obj$1.TAG;
120-
let tag = size << 10 | obj_tag;
120+
let tag = (size << 10) | obj_tag;
121121
s = hash_mix_int(s, tag);
122122
let v = size - 1 | 0;
123123
let block = v < num ? v : num;
@@ -133,7 +133,7 @@ function hash(count, _limit, seed, obj) {
133133
}
134134
return size
135135
})(obj$1, v => push_back(queue, v));
136-
s = hash_mix_int(s, size$1 << 10 | 0);
136+
s = hash_mix_int(s, (size$1 << 10) | 0);
137137
}
138138
}
139139

‎tests/tests/src/alias_default_value_test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function Alias_default_value_test$C0(props) {
55
let __b = props.b;
66
let __a = props.a;
77
let a = __a !== undefined ? __a : 2;
8-
let b = __b !== undefined ? __b : a << 1;
8+
let b = __b !== undefined ? __b : (a << 1);
99
return a + b | 0;
1010
}
1111

‎tests/tests/src/belt_list_test.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ Mocha.describe("Belt_list_test", () => {
657657
});
658658
let id = x => x;
659659
Mocha.test("map", () => {
660-
Test_utils.eq("File \"belt_list_test.res\", line 109, characters 7-14", Belt_List.map(Belt_List.makeBy(5, id), x => x << 1), {
660+
Test_utils.eq("File \"belt_list_test.res\", line 109, characters 7-14", Belt_List.map(Belt_List.makeBy(5, id), x => (x << 1)), {
661661
hd: 0,
662662
tl: {
663663
hd: 2,
@@ -686,7 +686,7 @@ Mocha.describe("Belt_list_test", () => {
686686
let length_10_id = Belt_List.makeBy(10, id);
687687
let length_8_id = Belt_List.makeBy(8, id);
688688
Mocha.test("mapWithIndex etc.", () => {
689-
let d = Belt_List.makeBy(10, x => x << 1);
689+
let d = Belt_List.makeBy(10, x => (x << 1));
690690
Test_utils.eq("File \"belt_list_test.res\", line 124, characters 7-14", Belt_List.zipBy(length_10_id, length_10_id, add), d);
691691
Test_utils.eq("File \"belt_list_test.res\", line 125, characters 7-14", Belt_List.zipBy(/* [] */0, {
692692
hd: 1,
@@ -697,15 +697,15 @@ Mocha.describe("Belt_list_test", () => {
697697
tl: /* [] */0
698698
}, /* [] */0, add), /* [] */0);
699699
Test_utils.eq("File \"belt_list_test.res\", line 127, characters 7-14", Belt_List.zipBy(/* [] */0, /* [] */0, add), /* [] */0);
700-
Test_utils.eq("File \"belt_list_test.res\", line 128, characters 7-14", Belt_List.zipBy(length_10_id, length_10_id, add), Belt_List.concat(Belt_List.map(length_8_id, x => x << 1), {
700+
Test_utils.eq("File \"belt_list_test.res\", line 128, characters 7-14", Belt_List.zipBy(length_10_id, length_10_id, add), Belt_List.concat(Belt_List.map(length_8_id, x => (x << 1)), {
701701
hd: 16,
702702
tl: {
703703
hd: 18,
704704
tl: /* [] */0
705705
}
706706
}));
707707
Test_utils.eq("File \"belt_list_test.res\", line 129, characters 7-14", Belt_List.zipBy(length_10_id, length_8_id, add), Belt_List.mapWithIndex(length_8_id, (i, x) => i + x | 0));
708-
Test_utils.eq("File \"belt_list_test.res\", line 131, characters 6-13", Belt_List.reverse(Belt_List.mapReverse2(length_10_id, length_10_id, add)), Belt_List.map(length_10_id, x => x << 1));
708+
Test_utils.eq("File \"belt_list_test.res\", line 131, characters 6-13", Belt_List.reverse(Belt_List.mapReverse2(length_10_id, length_10_id, add)), Belt_List.map(length_10_id, x => (x << 1)));
709709
let xs = Belt_List.reverse(Belt_List.mapReverse2(length_8_id, length_10_id, add));
710710
Test_utils.eq("File \"belt_list_test.res\", line 136, characters 7-14", Belt_List.length(xs), 8);
711711
Test_utils.eq("File \"belt_list_test.res\", line 137, characters 7-14", xs, Belt_List.zipBy(length_10_id, length_8_id, add));

‎tests/tests/src/belt_sortarray_test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ Mocha.describe("Belt_sortarray_test", () => {
268268
], 4, cmp), 3);
269269
let aa = Array_data_util.range(0, 1000);
270270
Test_utils.ok("File \"belt_sortarray_test.res\", line 115, characters 7-14", Belt_Range.every(0, 1000, i => Belt_SortArray.binarySearchBy(aa, i, cmp) === i));
271-
let cc = Belt_Array.map(Array_data_util.range(0, 2000), x => x << 1);
271+
let cc = Belt_Array.map(Array_data_util.range(0, 2000), x => (x << 1));
272272
Test_utils.eq("File \"belt_sortarray_test.res\", line 118, characters 7-14", Pervasives.lnot(Belt_SortArray.binarySearchBy(cc, 5000, cmp)), 2001);
273273
Test_utils.eq("File \"belt_sortarray_test.res\", line 119, characters 7-14", Pervasives.lnot(Belt_SortArray.binarySearchBy(cc, -1, cmp)), 0);
274274
Test_utils.eq("File \"belt_sortarray_test.res\", line 120, characters 7-14", Belt_SortArray.binarySearchBy(cc, 0, cmp), 0);

‎tests/tests/src/bigint_test.mjs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ function bigint_lxor(prim0, prim1) {
7474
}
7575

7676
function bigint_lsl(prim0, prim1) {
77-
return prim0 << prim1;
77+
return (prim0 << prim1);
7878
}
7979

8080
function bigint_asr(prim0, prim1) {
81-
return prim0 >> prim1;
81+
return (prim0 >> prim1);
8282
}
8383

8484
eq("File \"bigint_test.res\", line 26, characters 5-12", Primitive_bigint.compare(1n, 1n), 0);
@@ -135,17 +135,17 @@ eq("File \"bigint_test.res\", line 159, characters 5-12", 9n | 1n, 9n);
135135

136136
eq("File \"bigint_test.res\", line 160, characters 5-12", 9n ^ 1n, 8n);
137137

138-
eq("File \"bigint_test.res\", line 161, characters 5-12", 9n << 1n, 18n);
138+
eq("File \"bigint_test.res\", line 161, characters 5-12", (9n << 1n), 18n);
139139

140-
eq("File \"bigint_test.res\", line 162, characters 5-12", 9n << -1n, 4n);
140+
eq("File \"bigint_test.res\", line 162, characters 5-12", (9n << -1n), 4n);
141141

142-
eq("File \"bigint_test.res\", line 163, characters 5-12", 9n >> 1n, 4n);
142+
eq("File \"bigint_test.res\", line 163, characters 5-12", (9n >> 1n), 4n);
143143

144-
eq("File \"bigint_test.res\", line 164, characters 5-12", 9n >> -1n, 18n);
144+
eq("File \"bigint_test.res\", line 164, characters 5-12", (9n >> -1n), 18n);
145145

146-
eq("File \"bigint_test.res\", line 165, characters 5-12", -9n >> 1n, -5n);
146+
eq("File \"bigint_test.res\", line 165, characters 5-12", (-9n >> 1n), -5n);
147147

148-
eq("File \"bigint_test.res\", line 166, characters 5-12", -9n >> -1n, -18n);
148+
eq("File \"bigint_test.res\", line 166, characters 5-12", (-9n >> -1n), -18n);
149149

150150
eq("File \"bigint_test.res\", line 167, characters 5-12", 9n > 1n ? 9n : 1n, 9n);
151151

‎tests/tests/src/bs_mutable_set_test.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ for (let i$6 = 0; i$6 <= 200; ++i$6) {
447447

448448
eq("File \"bs_mutable_set_test.res\", line 244, characters 5-12", Belt_MutableSetInt.size(copyV), 126);
449449

450-
eq("File \"bs_mutable_set_test.res\", line 245, characters 5-12", Belt_MutableSetInt.toArray(copyV), Belt_Array.makeBy(126, i => i << 3));
450+
eq("File \"bs_mutable_set_test.res\", line 245, characters 5-12", Belt_MutableSetInt.toArray(copyV), Belt_Array.makeBy(126, i => (i << 3)));
451451

452452
eq("File \"bs_mutable_set_test.res\", line 246, characters 5-12", Belt_MutableSetInt.size(v$5), 800);
453453

@@ -465,13 +465,13 @@ b("File \"bs_mutable_set_test.res\", line 254, characters 4-11", Belt_MutableSet
465465

466466
b("File \"bs_mutable_set_test.res\", line 255, characters 4-11", Belt_MutableSetInt.eq(match$7[1], Belt_MutableSetInt.fromArray(Array_data_util.randomRange(401, 1000))));
467467

468-
let d = Belt_MutableSetInt.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 1000), x => x << 1));
468+
let d = Belt_MutableSetInt.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 1000), x => (x << 1)));
469469

470470
let match$8 = Belt_MutableSetInt.split(d, 1001);
471471

472472
let match$9 = match$8[0];
473473

474-
b("File \"bs_mutable_set_test.res\", line 258, characters 4-11", Belt_MutableSetInt.eq(match$9[0], Belt_MutableSetInt.fromArray(Belt_Array.makeBy(501, x => x << 1))));
474+
b("File \"bs_mutable_set_test.res\", line 258, characters 4-11", Belt_MutableSetInt.eq(match$9[0], Belt_MutableSetInt.fromArray(Belt_Array.makeBy(501, x => (x << 1)))));
475475

476476
b("File \"bs_mutable_set_test.res\", line 259, characters 4-11", Belt_MutableSetInt.eq(match$9[1], Belt_MutableSetInt.fromArray(Belt_Array.makeBy(500, x => 1002 + (x << 1) | 0))));
477477

‎tests/tests/src/bs_poly_set_test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ let u25 = Belt_Set.add(u22, 59);
141141

142142
let u26 = Belt_Set.add(Belt_Set.make(IntCmp), 3);
143143

144-
let ss = Belt_Array.makeByAndShuffle(100, i => i << 1);
144+
let ss = Belt_Array.makeByAndShuffle(100, i => (i << 1));
145145

146146
let u27 = Belt_Set.fromArray(ss, IntCmp);
147147

‎tests/tests/src/core/Core_TempTests.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ let array = [
2424
4
2525
];
2626

27-
console.info(Stdlib_Array.reduce(array.map(x => x << 1), 0, (a, b) => a + b | 0));
27+
console.info(Stdlib_Array.reduce(array.map(x => (x << 1)), 0, (a, b) => a + b | 0));
2828

2929
console.info(typeof array);
3030

‎tests/tests/src/for_loop_test.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function for_3(x) {
99
};
1010
let arr = Belt_Array.map(x, param => (() => {}));
1111
for (let i = 0, i_finish = x.length; i < i_finish; ++i) {
12-
let j = i << 1;
12+
let j = (i << 1);
1313
arr[i] = () => {
1414
v.contents = v.contents + j | 0;
1515
};
@@ -24,8 +24,8 @@ function for_4(x) {
2424
};
2525
let arr = Belt_Array.map(x, param => (() => {}));
2626
for (let i = 0, i_finish = x.length; i < i_finish; ++i) {
27-
let j = i << 1;
28-
let k = j << 1;
27+
let j = (i << 1);
28+
let k = (j << 1);
2929
arr[i] = () => {
3030
v.contents = v.contents + k | 0;
3131
};
@@ -69,7 +69,7 @@ function for_6(x, u) {
6969
};
7070
for (let i = 0, i_finish = x.length; i < i_finish; ++i) {
7171
let k = (u << 1) * u | 0;
72-
let h = v5.contents << 1;
72+
let h = (v5.contents << 1);
7373
v2.contents = v2.contents + 1 | 0;
7474
arr[i] = () => {
7575
v.contents = (((((v.contents + k | 0) + v2.contents | 0) + v4.contents | 0) + v5.contents | 0) + h | 0) + u | 0;
@@ -108,7 +108,7 @@ function for_8() {
108108
};
109109
let arr = Belt_Array.make(21, () => {});
110110
for (let i = 0; i <= 6; ++i) {
111-
let k = i << 1;
111+
let k = (i << 1);
112112
for (let j = 0; j <= 2; ++j) {
113113
let h = i + j | 0;
114114
arr[(i * 3 | 0) + j | 0] = () => {

‎tests/tests/src/gray_code_test.mjs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@
22

33

44
function gray_encode(b) {
5-
return b ^ b >>> 1;
5+
return b ^ (b >>> 1);
66
}
77

88
function gray_decode(n) {
99
let _p = n;
10-
let _n = n >>> 1;
10+
let _n = (n >>> 1);
1111
while (true) {
1212
let n$1 = _n;
1313
let p = _p;
1414
if (n$1 === 0) {
1515
return p;
1616
}
17-
_n = n$1 >>> 1;
17+
_n = (n$1 >>> 1);
1818
_p = p ^ n$1;
1919
continue;
2020
};
2121
}
2222

2323
function next_power(v) {
2424
let v$1 = v - 1 | 0;
25-
let v$2 = v$1 >>> 1 | v$1;
26-
let v$3 = v$2 >>> 2 | v$2;
27-
let v$4 = v$3 >>> 4 | v$3;
28-
let v$5 = v$4 >>> 8 | v$4;
29-
let v$6 = v$5 >>> 16 | v$5;
25+
let v$2 = (v$1 >>> 1) | v$1;
26+
let v$3 = (v$2 >>> 2) | v$2;
27+
let v$4 = (v$3 >>> 4) | v$3;
28+
let v$5 = (v$4 >>> 8) | v$4;
29+
let v$6 = (v$5 >>> 16) | v$5;
3030
return v$6 + 1 | 0;
3131
}
3232

‎tests/tests/src/js_array_test.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ let suites_1 = {
829829
2,
830830
3,
831831
4
832-
].map(n => n << 1)
832+
].map(n => (n << 1))
833833
})
834834
],
835835
tl: {
@@ -848,7 +848,7 @@ let suites_1 = {
848848
2,
849849
3,
850850
4
851-
].map((param, i) => i << 1)
851+
].map((param, i) => (i << 1))
852852
})
853853
],
854854
tl: {

‎tests/tests/src/js_null_test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ let suites_1 = {
6464
param => ({
6565
TAG: "StrictEq",
6666
_0: 4,
67-
_1: Js_null.bind(2, n => n << 1)
67+
_1: Js_null.bind(2, n => (n << 1))
6868
})
6969
],
7070
tl: {

‎tests/tests/src/js_null_undefined_test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ let suites_1 = {
118118
param => ({
119119
TAG: "Eq",
120120
_0: 4,
121-
_1: Js_null_undefined.bind(2, n => n << 1)
121+
_1: Js_null_undefined.bind(2, n => (n << 1))
122122
})
123123
],
124124
tl: {

‎tests/tests/src/js_undefined_test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ let suites_1 = {
6464
param => ({
6565
TAG: "Eq",
6666
_0: 4,
67-
_1: Js_undefined.bind(2, n => n << 1)
67+
_1: Js_undefined.bind(2, n => (n << 1))
6868
})
6969
],
7070
tl: {

‎tests/tests/src/mario_game.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2002,7 +2002,7 @@ function process_collision(dir, c1, c2, state) {
20022002
let score = 100 * state.multiplier | 0;
20032003
update_score(state, score);
20042004
o2.score = score;
2005-
state.multiplier = state.multiplier << 1;
2005+
state.multiplier = (state.multiplier << 1);
20062006
return [
20072007
undefined,
20082008
evolve_enemy(o1.dir, typ, s2, o2, context)

‎tests/tests/src/ocaml_compat/Ocaml_List.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ function stable_sort(cmp, l) {
860860
}
861861

862862
}
863-
let n1 = n >> 1;
863+
let n1 = (n >> 1);
864864
let n2 = n - n1 | 0;
865865
let l2 = chop(n1, l);
866866
let s1 = rev_sort(n1, l);
@@ -1006,7 +1006,7 @@ function stable_sort(cmp, l) {
10061006
}
10071007

10081008
}
1009-
let n1 = n >> 1;
1009+
let n1 = (n >> 1);
10101010
let n2 = n - n1 | 0;
10111011
let l2 = chop(n1, l);
10121012
let s1 = sort(n1, l);
@@ -1234,7 +1234,7 @@ function sort_uniq(cmp, l) {
12341234
}
12351235

12361236
}
1237-
let n1 = n >> 1;
1237+
let n1 = (n >> 1);
12381238
let n2 = n - n1 | 0;
12391239
let l2 = chop(n1, l);
12401240
let s1 = rev_sort(n1, l);
@@ -1465,7 +1465,7 @@ function sort_uniq(cmp, l) {
14651465
}
14661466

14671467
}
1468-
let n1 = n >> 1;
1468+
let n1 = (n >> 1);
14691469
let n2 = n - n1 | 0;
14701470
let l2 = chop(n1, l);
14711471
let s1 = sort(n1, l);

‎tests/tests/src/record_name_test.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function f(x) {
99

1010
function set(x) {
1111
x.THIS_IS_NOT_EXPRESSIBLE_IN_BUCKLE = 3;
12-
return x.THIS_IS_NOT_EXPRESSIBLE_IN_BUCKLE << 1;
12+
return (x.THIS_IS_NOT_EXPRESSIBLE_IN_BUCKLE << 1);
1313
}
1414

1515
function f1(u) {
@@ -31,7 +31,7 @@ function f3(x) {
3131
}
3232

3333
function f4(param) {
34-
return ((param.EXACT_MAPPING_TO_JS_LABEL + param.EXACT_2 | 0) + param.z.hello | 0) << 1;
34+
return (((param.EXACT_MAPPING_TO_JS_LABEL + param.EXACT_2 | 0) + param.z.hello | 0) << 1);
3535
}
3636

3737
function u() {

‎tests/tests/src/test_for_loop.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function for_3(x) {
2020
};
2121
let arr = Belt_Array.map(x, param => (() => {}));
2222
for (let i = 0, i_finish = x.length; i <= i_finish; ++i) {
23-
let j = i << 1;
23+
let j = (i << 1);
2424
arr[i] = () => {
2525
v.contents = v.contents + j | 0;
2626
};
@@ -35,8 +35,8 @@ function for_4(x) {
3535
};
3636
let arr = Belt_Array.map(x, param => (() => {}));
3737
for (let i = 0, i_finish = x.length; i <= i_finish; ++i) {
38-
let j = i << 1;
39-
let k = j << 1;
38+
let j = (i << 1);
39+
let k = (j << 1);
4040
arr[i] = () => {
4141
v.contents = v.contents + k | 0;
4242
};
@@ -79,7 +79,7 @@ function for_6(x, u) {
7979
};
8080
for (let i = 0, i_finish = x.length; i <= i_finish; ++i) {
8181
let k = (u << 1) * u | 0;
82-
let h = v5.contents << 1;
82+
let h = (v5.contents << 1);
8383
v2.contents = v2.contents + 1 | 0;
8484
arr[i] = () => {
8585
v.contents = (((((v.contents + k | 0) + v2.contents | 0) + u | 0) + v4.contents | 0) + v5.contents | 0) + h | 0;

‎tests/tests/src/test_list.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ function stable_sort(cmp, l) {
754754
}
755755

756756
}
757-
let n1 = n >> 1;
757+
let n1 = (n >> 1);
758758
let n2 = n - n1 | 0;
759759
let l2 = chop(n1, l);
760760
let s1 = rev_sort(n1, l);
@@ -900,7 +900,7 @@ function stable_sort(cmp, l) {
900900
}
901901

902902
}
903-
let n1 = n >> 1;
903+
let n1 = (n >> 1);
904904
let n2 = n - n1 | 0;
905905
let l2 = chop(n1, l);
906906
let s1 = sort(n1, l);
@@ -1128,7 +1128,7 @@ function sort_uniq(cmp, l) {
11281128
}
11291129

11301130
}
1131-
let n1 = n >> 1;
1131+
let n1 = (n >> 1);
11321132
let n2 = n - n1 | 0;
11331133
let l2 = chop(n1, l);
11341134
let s1 = rev_sort(n1, l);
@@ -1359,7 +1359,7 @@ function sort_uniq(cmp, l) {
13591359
}
13601360

13611361
}
1362-
let n1 = n >> 1;
1362+
let n1 = (n >> 1);
13631363
let n2 = n - n1 | 0;
13641364
let l2 = chop(n1, l);
13651365
let s1 = sort(n1, l);

‎tests/tests/src/test_tuple.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ for (let k = 1; k <= 10; ++k) {
77
for (let i = 1; i <= 10; ++i) {
88
let match = i % 2 === 0 ? [
99
1,
10-
i << 1
10+
(i << 1)
1111
] : [
1212
2,
1313
i * 3 | 0

‎tests/tests/src/unified_ops_test.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ function bxor_bigint(a, b) {
7575
return a ^ b;
7676
}
7777

78-
let shl_bigint = 1n << 2n;
78+
let shl_bigint = (1n << 2n);
7979

80-
let shr_bigint = 8n >> 2n;
80+
let shr_bigint = (8n >> 2n);
8181

8282
let int = 3;
8383

0 commit comments

Comments
 (0)
Please sign in to comment.