Skip to content

Commit 60b99ea

Browse files
committed
respect declaration order
1 parent 5b73fb3 commit 60b99ea

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

compiler/ml/ast_untagged_variants.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ module DynamicChecks = struct
468468
in
469469
if list_literal_cases then
470470
let rec mk cases =
471-
match cases with
471+
match List.rev cases with
472472
| [case] -> is_literal_case case
473473
| case :: rest -> is_literal_case case ||| mk rest
474474
| [] -> assert false

tests/tests/src/UntaggedVariants.mjs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ let Truthy = {
8080
};
8181

8282
function classify$1(x) {
83-
if (x === undefined || x === null) {
83+
if (x === null || x === undefined) {
8484
if (x === null) {
8585
return "null";
8686
} else {
@@ -96,7 +96,7 @@ let TwoObjects = {
9696
};
9797

9898
function classify$2(x) {
99-
if (x === "B" || x === "A") {
99+
if (x === "A" || x === "B") {
100100
if (x === "A") {
101101
return "a";
102102
} else {
@@ -112,7 +112,7 @@ let Unknown = {
112112
};
113113

114114
function classify$3(x) {
115-
if (x === "D" || x === "C" || x === "B" || x === "A") {
115+
if (x === "A" || x === "D" || x === "B" || x === "C") {
116116
switch (x) {
117117
case "A" :
118118
return "a";
@@ -173,7 +173,7 @@ let WithArray = {
173173
};
174174

175175
function classify$6(x) {
176-
if (x === null || x === true || x === false) {
176+
if (x === false || x === null || x === true) {
177177
switch (x) {
178178
case false :
179179
return "JSONFalse";
@@ -234,7 +234,7 @@ let TrickyNested = {
234234
};
235235

236236
function checkEnum(e) {
237-
if (!(e === "Three" || e === "Two" || e === "One")) {
237+
if (!(e === "One" || e === "Three" || e === "Two")) {
238238
return "Something else..." + e;
239239
}
240240
switch (e) {
@@ -252,7 +252,7 @@ let OverlapString = {
252252
};
253253

254254
function checkEnum$1(e) {
255-
if (!(e === "Three" || e === "Two" || e === 1.0)) {
255+
if (!(e === 1.0 || e === "Three" || e === "Two")) {
256256
return "Something else...";
257257
}
258258
switch (e) {
@@ -376,7 +376,7 @@ let TestFunctionCase = {
376376
let someJson = '[{"name": "Haan"}, {"name": "Mr"}, false]';
377377

378378
function check$1(s) {
379-
if (s === null || s === true || s === false || s === undefined) {
379+
if (s === undefined || s === null || s === false || s === true) {
380380
console.log("Nope...");
381381
return;
382382
}
@@ -390,7 +390,7 @@ function check$1(s) {
390390
let match$1 = s[1];
391391
if (match$1 === false) {
392392
let match$2 = s[2];
393-
if (match$2 === null || match$2 === true || match$2 === false || match$2 === undefined) {
393+
if (match$2 === undefined || match$2 === null || match$2 === false || match$2 === true) {
394394
console.log("Nope...");
395395
return;
396396
}
@@ -400,13 +400,13 @@ function check$1(s) {
400400
return;
401401
}
402402
let match$3 = match$2[0];
403-
if (match$3 === null || match$3 === true || match$3 === false || match$3 === undefined) {
403+
if (match$3 === undefined || match$3 === null || match$3 === false || match$3 === true) {
404404
console.log("Nope...");
405405
return;
406406
}
407407
if (typeof match$3 === "string" && match$3 === "My name is") {
408408
let match$4 = match$2[1];
409-
if (match$4 === null || match$4 === true || match$4 === false || match$4 === undefined) {
409+
if (match$4 === undefined || match$4 === null || match$4 === false || match$4 === true) {
410410
console.log("Nope...");
411411
return;
412412
}
@@ -476,7 +476,7 @@ let PromiseSync = {
476476
};
477477

478478
async function classify$10(a) {
479-
if (a === 12 || a === "test") {
479+
if (a === "test" || a === 12) {
480480
if (a === "test") {
481481
console.log("testing");
482482
return;

tests/tests/src/core/Core_NullableTests.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function shouldHandleNullableValues() {
77
let tUndefined = undefined;
88
let tValue = "hello";
99
let tmp;
10-
tmp = (tNull === undefined || tNull === null) && tNull === null ? true : false;
10+
tmp = (tNull === null || tNull === undefined) && tNull === null ? true : false;
1111
Test.run([
1212
[
1313
"Core_NullableTests.res",
@@ -18,7 +18,7 @@ function shouldHandleNullableValues() {
1818
"Should handle null"
1919
], tmp, (prim0, prim1) => prim0 === prim1, true);
2020
let tmp$1;
21-
tmp$1 = (tUndefined === undefined || tUndefined === null) && tUndefined !== null ? true : false;
21+
tmp$1 = (tUndefined === null || tUndefined === undefined) && tUndefined !== null ? true : false;
2222
Test.run([
2323
[
2424
"Core_NullableTests.res",
@@ -29,7 +29,7 @@ function shouldHandleNullableValues() {
2929
"Should handle undefined"
3030
], tmp$1, (prim0, prim1) => prim0 === prim1, true);
3131
let tmp$2;
32-
tmp$2 = tValue === undefined || tValue === null || tValue !== "hello" ? false : true;
32+
tmp$2 = tValue === null || tValue === undefined || tValue !== "hello" ? false : true;
3333
Test.run([
3434
[
3535
"Core_NullableTests.res",

tests/tests/src/variantsMatching.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,17 +224,17 @@ function isUndefined$1(x) {
224224
}
225225

226226
function plus$2(x, y) {
227-
if (x === undefined || x === null) {
227+
if (x === null || x === undefined) {
228228
return y;
229-
} else if (y === undefined || y === null) {
229+
} else if (y === null || y === undefined) {
230230
return x;
231231
} else {
232232
return x + y | 0;
233233
}
234234
}
235235

236236
function kind(x) {
237-
if (x === undefined || x === null) {
237+
if (x === null || x === undefined) {
238238
if (x === null) {
239239
return "null";
240240
} else {
@@ -274,21 +274,21 @@ function isWhyNot(x) {
274274
}
275275

276276
function plus$3(x, y) {
277-
if (x === "WhyNotAnotherOne" || x === undefined || x === null) {
277+
if (x === null || x === "WhyNotAnotherOne" || x === undefined) {
278278
switch (x) {
279279
case null :
280280
case undefined :
281281
return y;
282282
case "WhyNotAnotherOne" :
283283
break;
284284
}
285-
} else if (!(y === "WhyNotAnotherOne" || y === undefined || y === null)) {
285+
} else if (!(y === null || y === "WhyNotAnotherOne" || y === undefined)) {
286286
return {
287287
x: x.x + y.x,
288288
y: x.y + y.y
289289
};
290290
}
291-
if (!(y === "WhyNotAnotherOne" || y === undefined || y === null)) {
291+
if (!(y === null || y === "WhyNotAnotherOne" || y === undefined)) {
292292
return "WhyNotAnotherOne";
293293
}
294294
switch (y) {
@@ -301,7 +301,7 @@ function plus$3(x, y) {
301301
}
302302

303303
function kind$1(x) {
304-
if (!(x === "WhyNotAnotherOne" || x === undefined || x === null)) {
304+
if (!(x === null || x === "WhyNotAnotherOne" || x === undefined)) {
305305
return "present";
306306
}
307307
switch (x) {

0 commit comments

Comments
 (0)