Skip to content

Commit 7bd9255

Browse files
committed
fix #4990
1 parent 54a40a0 commit 7bd9255

File tree

7 files changed

+98
-5
lines changed

7 files changed

+98
-5
lines changed

jscomp/core/lam.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ let if_ (a : t) (b : t) (c : t) : t =
788788
| Lprim(
789789
{primitive = Pnot ; args = [Lprim{primitive = Pintcomp Ceq ; args = [Lvar j; Lconst _] as args; loc}]})
790790
when Ident.same i j && eq_approx true_ c
791-
-> Lprim{primitive = Pintcomp Ceq; args; loc}
791+
-> Lprim{primitive = Pintcomp Cneq; args; loc}
792792
| _ -> Lifthenelse(a,b,c)
793793
end
794794
| _ -> Lifthenelse (a,b,c))

jscomp/test/build.ninja

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,8 @@ o test/gpr_4494_test.cmi test/gpr_4494_test.cmj : cc test/gpr_4494_test.ml | $st
333333
o test/gpr_4519_test.cmi test/gpr_4519_test.cmj : cc test/gpr_4519_test.ml | test/mt.cmj $stdlib
334334
o test/gpr_459_test.cmi test/gpr_459_test.cmj : cc test/gpr_459_test.ml | test/mt.cmj $stdlib
335335
o test/gpr_4639_test.cmi test/gpr_4639_test.cmj : cc test/gpr_4639_test.ml | $stdlib
336-
o test/gpr_4924_test.cmi test/gpr_4924_test.cmj : cc test/gpr_4924_test.ml | $stdlib
336+
o test/gpr_4900_test.cmi test/gpr_4900_test.cmj : cc test/gpr_4900_test.ml | test/mt.cmj $stdlib
337+
o test/gpr_4924_test.cmi test/gpr_4924_test.cmj : cc test/gpr_4924_test.ml | test/mt.cmj $stdlib
337338
o test/gpr_4931.cmi test/gpr_4931.cmj : cc test/gpr_4931.ml | $stdlib
338339
o test/gpr_627_test.cmi test/gpr_627_test.cmj : cc test/gpr_627_test.ml | test/mt.cmj $stdlib
339340
o test/gpr_658.cmi test/gpr_658.cmj : cc test/gpr_658.ml | $stdlib

jscomp/test/gpr_4900_test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict';
2+
3+
var Mt = require("./mt.js");
4+
5+
var suites = {
6+
contents: /* [] */0
7+
};
8+
9+
var id = {
10+
contents: 0
11+
};
12+
13+
function showToJs(x) {
14+
return x !== 0;
15+
}
16+
17+
Mt.eq_suites(id, suites, "File \"gpr_4900_test.ml\", line 15, characters 23-30", showToJs(/* Yes */1), true);
18+
19+
Mt.eq_suites(id, suites, "File \"gpr_4900_test.ml\", line 16, characters 23-30", showToJs(/* No */0), false);
20+
21+
Mt.eq_suites(id, suites, "File \"gpr_4900_test.ml\", line 17, characters 23-30", showToJs(/* After */{
22+
_0: 3
23+
}), true);
24+
25+
Mt.from_pair_suites("File \"gpr_4900_test.ml\", line 19, characters 20-27", suites.contents);
26+
27+
var from_pair_suites = Mt.from_pair_suites;
28+
29+
var eq_suites = Mt.eq_suites;
30+
31+
exports.from_pair_suites = from_pair_suites;
32+
exports.eq_suites = eq_suites;
33+
exports.suites = suites;
34+
exports.id = id;
35+
exports.showToJs = showToJs;
36+
/* Not a pure module */

jscomp/test/gpr_4900_test.ml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
3+
let {from_pair_suites;eq_suites} = (module Mt )
4+
5+
let suites = ref []
6+
let id = ref 0
7+
type show = | No | After of int | Yes
8+
9+
10+
let showToJs x =
11+
match x with
12+
| Yes | After _ -> true
13+
| No -> false
14+
15+
;; eq_suites id suites __LOC__ (showToJs Yes) true
16+
;; eq_suites id suites __LOC__ (showToJs No) false
17+
;; eq_suites id suites __LOC__ (showToJs (After 3)) true
18+
19+
;; from_pair_suites __LOC__ !suites

jscomp/test/gpr_4924_test.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
'use strict';
22

3+
var Mt = require("./mt.js");
4+
5+
var suites = {
6+
contents: /* [] */0
7+
};
8+
9+
var id = {
10+
contents: 0
11+
};
312

413
function u(b) {
514
if (b === 0) {
@@ -14,9 +23,17 @@ function u1(b) {
1423
}
1524

1625
function u2(b) {
17-
return b === 0;
26+
return b !== 0;
1827
}
1928

29+
Mt.eq_suites(id, suites, "File \"gpr_4924_test.ml\", line 25, characters 23-30", u2(/* A */0), false);
30+
31+
Mt.eq_suites(id, suites, "File \"gpr_4924_test.ml\", line 26, characters 23-30", u2(/* B */1), true);
32+
33+
Mt.eq_suites(id, suites, "File \"gpr_4924_test.ml\", line 27, characters 23-30", u2(/* C */{
34+
_0: 2
35+
}), true);
36+
2037
function u3(b) {
2138
if (b === 0) {
2239
return 3;
@@ -41,11 +58,21 @@ function u6(b) {
4158
return b === 0;
4259
}
4360

61+
Mt.from_pair_suites("File \"gpr_4924_test.ml\", line 49, characters 20-27", suites.contents);
62+
63+
var from_pair_suites = Mt.from_pair_suites;
64+
65+
var eq_suites = Mt.eq_suites;
66+
67+
exports.from_pair_suites = from_pair_suites;
68+
exports.eq_suites = eq_suites;
69+
exports.suites = suites;
70+
exports.id = id;
4471
exports.u = u;
4572
exports.u1 = u1;
4673
exports.u2 = u2;
4774
exports.u3 = u3;
4875
exports.u4 = u4;
4976
exports.u5 = u5;
5077
exports.u6 = u6;
51-
/* No side effect */
78+
/* Not a pure module */

jscomp/test/gpr_4924_test.ml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
let {from_pair_suites;eq_suites} = (module Mt )
2+
let suites = ref []
3+
let id = ref 0
4+
15
type t =
26
| A
37
| B
@@ -18,6 +22,9 @@ let u2 b =
1822
| A -> false
1923
| B | C _ -> true
2024

25+
;; eq_suites id suites __LOC__ (u2 A) false
26+
;; eq_suites id suites __LOC__ (u2 B ) true
27+
;; eq_suites id suites __LOC__ (u2 (C 2)) true
2128
let u3 b =
2229
match b with
2330
| A -> 3
@@ -37,3 +44,6 @@ let u6 b =
3744
match b with
3845
| A -> true
3946
| _ -> false
47+
48+
49+
;; from_pair_suites __LOC__ !suites

jscomp/test/ocaml_typedtree_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27272,7 +27272,7 @@ function in_pervasives(p) {
2727227272

2727327273
function is_datatype(decl) {
2727427274
var match = decl.type_kind;
27275-
return match === 0;
27275+
return match !== 0;
2727627276
}
2727727277

2727827278
function object_fields(ty) {

0 commit comments

Comments
 (0)