Skip to content

Commit ec3cf2d

Browse files
committed
Fix nullable to opt conversion.
1 parent 6a30fa2 commit ec3cf2d

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

compiler/ml/translcore.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ let primitives_table =
393393
("#typeof", Ptypeof);
394394
("#is_nullable", Pisnullable);
395395
("#null_to_opt", Pnullable_to_opt);
396-
("#nullable_to_opt", Pnull_to_opt);
396+
("#nullable_to_opt", Pnullable_to_opt);
397397
("#undefined_to_opt", Pundefined_to_opt);
398398
("#makemutablelist", Pmakelist Mutable);
399399
("#import", Pimport);

lib/es6/Nullable.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ function fromOption(option) {
1111
}
1212

1313
function equal(a, b, eq) {
14-
return Option.equal(a === null ? undefined : Primitive_option.some(a), b === null ? undefined : Primitive_option.some(b), eq);
14+
return Option.equal((a == null) ? undefined : Primitive_option.some(a), (b == null) ? undefined : Primitive_option.some(b), eq);
1515
}
1616

1717
function compare(a, b, cmp) {
18-
return Option.compare(a === null ? undefined : Primitive_option.some(a), b === null ? undefined : Primitive_option.some(b), cmp);
18+
return Option.compare((a == null) ? undefined : Primitive_option.some(a), (b == null) ? undefined : Primitive_option.some(b), cmp);
1919
}
2020

2121
function getOr(value, $$default) {
22-
if (value !== null) {
23-
return value;
24-
} else {
22+
if (value == null) {
2523
return $$default;
24+
} else {
25+
return value;
2626
}
2727
}
2828

2929
function getExn(value) {
30-
if (value !== null) {
30+
if (!(value == null)) {
3131
return value;
3232
}
3333
throw {
@@ -38,33 +38,33 @@ function getExn(value) {
3838
}
3939

4040
function forEach(value, f) {
41-
if (value !== null) {
41+
if (!(value == null)) {
4242
return f(value);
4343
}
4444

4545
}
4646

4747
function map(value, f) {
48-
if (value !== null) {
49-
return f(value);
50-
} else {
48+
if (value == null) {
5149
return value;
50+
} else {
51+
return f(value);
5252
}
5353
}
5454

5555
function mapOr(value, $$default, f) {
56-
if (value !== null) {
57-
return f(value);
58-
} else {
56+
if (value == null) {
5957
return $$default;
58+
} else {
59+
return f(value);
6060
}
6161
}
6262

6363
function flatMap(value, f) {
64-
if (value !== null) {
65-
return f(value);
66-
} else {
64+
if (value == null) {
6765
return value;
66+
} else {
67+
return f(value);
6868
}
6969
}
7070

lib/js/Nullable.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ function fromOption(option) {
1111
}
1212

1313
function equal(a, b, eq) {
14-
return Option.equal(a === null ? undefined : Primitive_option.some(a), b === null ? undefined : Primitive_option.some(b), eq);
14+
return Option.equal((a == null) ? undefined : Primitive_option.some(a), (b == null) ? undefined : Primitive_option.some(b), eq);
1515
}
1616

1717
function compare(a, b, cmp) {
18-
return Option.compare(a === null ? undefined : Primitive_option.some(a), b === null ? undefined : Primitive_option.some(b), cmp);
18+
return Option.compare((a == null) ? undefined : Primitive_option.some(a), (b == null) ? undefined : Primitive_option.some(b), cmp);
1919
}
2020

2121
function getOr(value, $$default) {
22-
if (value !== null) {
23-
return value;
24-
} else {
22+
if (value == null) {
2523
return $$default;
24+
} else {
25+
return value;
2626
}
2727
}
2828

2929
function getExn(value) {
30-
if (value !== null) {
30+
if (!(value == null)) {
3131
return value;
3232
}
3333
throw {
@@ -38,33 +38,33 @@ function getExn(value) {
3838
}
3939

4040
function forEach(value, f) {
41-
if (value !== null) {
41+
if (!(value == null)) {
4242
return f(value);
4343
}
4444

4545
}
4646

4747
function map(value, f) {
48-
if (value !== null) {
49-
return f(value);
50-
} else {
48+
if (value == null) {
5149
return value;
50+
} else {
51+
return f(value);
5252
}
5353
}
5454

5555
function mapOr(value, $$default, f) {
56-
if (value !== null) {
57-
return f(value);
58-
} else {
56+
if (value == null) {
5957
return $$default;
58+
} else {
59+
return f(value);
6060
}
6161
}
6262

6363
function flatMap(value, f) {
64-
if (value !== null) {
65-
return f(value);
66-
} else {
64+
if (value == null) {
6765
return value;
66+
} else {
67+
return f(value);
6868
}
6969
}
7070

0 commit comments

Comments
 (0)