Skip to content

Commit 0304ac3

Browse files
committed
fix #4280
1 parent 3613522 commit 0304ac3

17 files changed

+1507
-1214
lines changed

jscomp/core/lam_compile.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,8 +811,12 @@ and compile_staticcatch (lam : Lam.t) (lambda_cxt : Lam_compile_context.t)=
811811
(* place holder -- tell the compiler that
812812
we don't know if it's complete
813813
*)
814-
| EffectCall tail_type ->
815-
let new_cxt = {lambda_cxt with jmp_table = jmp_table } in
814+
| EffectCall tail_type as cont ->
815+
let continuation =
816+
let new_tail_type = (in_staticcatch tail_type) in
817+
if new_tail_type == tail_type then cont else EffectCall new_tail_type
818+
in
819+
let new_cxt = {lambda_cxt with jmp_table = jmp_table ; continuation } in
816820
let lbody = compile_lambda new_cxt body in
817821
Js_output.append_output (Js_output.make declares)
818822
(Js_output.append_output lbody

jscomp/test/build.ninja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ build test/gpr_405_test.cmj : cc_cmi test/gpr_405_test.ml | test/gpr_405_test.cm
320320
build test/gpr_405_test.cmi : cc test/gpr_405_test.mli | $stdlib
321321
build test/gpr_4069_test.cmi test/gpr_4069_test.cmj : cc test/gpr_4069_test.ml | $stdlib
322322
build test/gpr_4265_test.cmi test/gpr_4265_test.cmj : cc test/gpr_4265_test.ml | test/mt.cmj $stdlib
323-
build test/gpr_4280_test.cmi test/gpr_4280_test.cmj : cc test/gpr_4280_test.ml | $stdlib
323+
build test/gpr_4280_test.cmi test/gpr_4280_test.cmj : cc test/gpr_4280_test.ml | test/mt.cmj $stdlib
324324
build test/gpr_441.cmi test/gpr_441.cmj : cc test/gpr_441.ml | $stdlib
325325
build test/gpr_459_test.cmi test/gpr_459_test.cmj : cc test/gpr_459_test.ml | test/mt.cmj $stdlib
326326
build test/gpr_627_test.cmi test/gpr_627_test.cmj : cc test/gpr_627_test.ml | test/mt.cmj $stdlib

jscomp/test/gpr_4280_test.js

Lines changed: 66 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
'use strict';
22

3-
var Caml_builtin_exceptions = require("../../lib/js/caml_builtin_exceptions.js");
3+
var Mt = require("./mt.js");
4+
5+
var suites = {
6+
contents: /* [] */0
7+
};
8+
9+
var test_id = {
10+
contents: 0
11+
};
12+
13+
function eq(loc, x, y) {
14+
return Mt.eq_suites(test_id, suites, loc, x, y);
15+
}
416

517
var u = {
618
contents: 0
@@ -26,36 +38,51 @@ function fn(authState, route) {
2638
var exit = 0;
2739
var onboardingRoute;
2840
if (typeof authState === "number") {
41+
var exit$1 = 0;
2942
if (typeof route === "number") {
3043
if (route >= -730831382) {
31-
if (!(route !== -384135774 && route !== -384133096)) {
44+
if (route !== -384135774 && route !== -384133096) {
45+
exit$1 = 3;
46+
} else {
3247
exit = 2;
3348
}
34-
35-
} else if (!(route !== -799423340 && route < -730831383)) {
49+
} else if (route !== -799423340 && route < -730831383) {
50+
exit$1 = 3;
51+
} else {
3652
exit = 2;
3753
}
38-
39-
} else if (route[0] === 378129979) {
54+
} else if (route[0] !== 378129979) {
55+
exit$1 = 3;
56+
} else {
4057
onboardingRoute = route[1];
4158
exit = 1;
4259
}
43-
div(/* :: */[
44-
string("Redirect"),
45-
/* [] */0
46-
], undefined);
47-
return 3;
48-
}
49-
if (typeof route !== "number" && route[0] === 378129979) {
50-
onboardingRoute = route[1];
51-
exit = 1;
60+
if (exit$1 === 3) {
61+
div(/* :: */[
62+
string("Redirect"),
63+
/* [] */0
64+
], undefined);
65+
return 3;
66+
}
67+
68+
} else {
69+
var exit$2 = 0;
70+
if (typeof route === "number" || route[0] !== 378129979) {
71+
exit$2 = 3;
72+
} else {
73+
onboardingRoute = route[1];
74+
exit = 1;
75+
}
76+
if (exit$2 === 3) {
77+
console.log(authState[1]);
78+
div(/* :: */[
79+
string("VerifyEmail"),
80+
/* [] */0
81+
], undefined);
82+
return 2;
83+
}
84+
5285
}
53-
console.log(authState[1]);
54-
div(/* :: */[
55-
string("VerifyEmail"),
56-
/* [] */0
57-
], undefined);
58-
return 2;
5986
switch (exit) {
6087
case 1 :
6188
console.log(onboardingRoute);
@@ -74,17 +101,25 @@ function fn(authState, route) {
74101
}
75102
}
76103

77-
if (fn(/* Unauthenticated */-54822762, /* Invite */-730831383) !== 1) {
78-
throw [
79-
Caml_builtin_exceptions.assert_failure,
80-
/* tuple */[
81-
"gpr_4280_test.ml",
82-
40,
83-
3
84-
]
85-
];
86-
}
104+
eq("File \"gpr_4280_test.ml\", line 46, characters 6-13", fn(/* Unauthenticated */-54822762, /* Invite */-730831383), 1);
105+
106+
eq("File \"gpr_4280_test.ml\", line 47, characters 6-13", fn(/* Unauthenticated */-54822762, /* `Onboarding */[
107+
378129979,
108+
0
109+
]), 0);
110+
111+
eq("File \"gpr_4280_test.ml\", line 48, characters 6-13", fn(/* `Unverified */[
112+
254489473,
113+
0
114+
], /* Invite */-730831383), 2);
115+
116+
eq("File \"gpr_4280_test.ml\", line 49, characters 6-13", fn(/* Unauthenticated */-54822762, /* xx */26880), 3);
117+
118+
Mt.from_pair_suites("gpr_4280_test.ml", suites.contents);
87119

120+
exports.suites = suites;
121+
exports.test_id = test_id;
122+
exports.eq = eq;
88123
exports.u = u;
89124
exports.div = div;
90125
exports.string = string;

jscomp/test/gpr_4280_test.ml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[@@@bs.config {flags = [|"-bs-diagnose"|]}]
2+
let suites : Mt.pair_suites ref = ref []
3+
let test_id = ref 0
4+
let eq loc x y = Mt.eq_suites ~test_id ~suites loc x y
15

26
let u = ref 0
37
let div ~children () =
@@ -6,11 +10,11 @@ let div ~children () =
610
Js.log "nonline"
711
done
812

9-
let string (s : string) =
10-
for i = 0 to 1 do
11-
u := 200;
12-
Js.log "no"
13-
done
13+
let string (s : string) =
14+
for i = 0 to 1 do
15+
u := 200;
16+
Js.log "no"
17+
done
1418

1519
let fn authState route =
1620
match (authState, route) with
@@ -37,4 +41,10 @@ let fn authState route =
3741
div
3842
~children:[string
3943
"Redirect"] ();3
40-
;; assert (fn (`Unauthenticated) `Invite = 1 ) (* == 1*)
44+
45+
46+
;; eq __LOC__ (fn (`Unauthenticated) `Invite) 1
47+
;; eq __LOC__ (fn (`Unauthenticated) (`Onboarding 0)) 0
48+
;; eq __LOC__ (fn (`Unverified 0) `Invite) 2
49+
;; eq __LOC__ (fn `Unauthenticated `xx) 3
50+
;; Mt.from_pair_suites __FILE__ !suites

jscomp/test/mario_game.js

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,65 +1661,71 @@ function process_collision(dir, c1, c2, state) {
16611661
var o2$4 = c2[2];
16621662
var t = c2[0];
16631663
if (dir !== 0) {
1664+
var exit$1 = 0;
16641665
if (typeof t === "number" && t === 4) {
16651666
game_win(state.ctx);
16661667
return /* tuple */[
16671668
undefined,
16681669
undefined
16691670
];
16701671
}
1671-
if (dir !== 1) {
1672-
collide_block(undefined, dir, o1$3);
1673-
return /* tuple */[
1674-
undefined,
1675-
undefined
1676-
];
1677-
} else {
1678-
state.multiplier = 1;
1679-
collide_block(undefined, dir, o1$3);
1680-
return /* tuple */[
1681-
undefined,
1682-
undefined
1683-
];
1672+
exit$1 = 4;
1673+
if (exit$1 === 4) {
1674+
if (dir !== 1) {
1675+
collide_block(undefined, dir, o1$3);
1676+
return /* tuple */[
1677+
undefined,
1678+
undefined
1679+
];
1680+
} else {
1681+
state.multiplier = 1;
1682+
collide_block(undefined, dir, o1$3);
1683+
return /* tuple */[
1684+
undefined,
1685+
undefined
1686+
];
1687+
}
16841688
}
1685-
}
1686-
if (typeof t === "number") {
1687-
if (t !== 1) {
1688-
if (t !== 4) {
1689+
1690+
} else {
1691+
if (typeof t === "number") {
1692+
if (t !== 1) {
1693+
if (t !== 4) {
1694+
collide_block(undefined, dir, o1$3);
1695+
return /* tuple */[
1696+
undefined,
1697+
undefined
1698+
];
1699+
} else {
1700+
game_win(state.ctx);
1701+
return /* tuple */[
1702+
undefined,
1703+
undefined
1704+
];
1705+
}
1706+
} else if (c1[0] === /* BigM */0) {
16891707
collide_block(undefined, dir, o1$3);
1708+
dec_health(o2$4);
16901709
return /* tuple */[
16911710
undefined,
16921711
undefined
16931712
];
16941713
} else {
1695-
game_win(state.ctx);
1714+
collide_block(undefined, dir, o1$3);
16961715
return /* tuple */[
16971716
undefined,
16981717
undefined
16991718
];
17001719
}
1701-
} else if (c1[0] === /* BigM */0) {
1702-
collide_block(undefined, dir, o1$3);
1703-
dec_health(o2$4);
1704-
return /* tuple */[
1705-
undefined,
1706-
undefined
1707-
];
1708-
} else {
1709-
collide_block(undefined, dir, o1$3);
1710-
return /* tuple */[
1711-
undefined,
1712-
undefined
1713-
];
17141720
}
1721+
var updated_block = evolve_block(o2$4, context);
1722+
var spawned_item = spawn_above(o1$3.dir, o2$4, t[0], context);
1723+
collide_block(undefined, dir, o1$3);
1724+
return /* tuple */[
1725+
spawned_item,
1726+
updated_block
1727+
];
17151728
}
1716-
var updated_block = evolve_block(o2$4, context);
1717-
var spawned_item = spawn_above(o1$3.dir, o2$4, t[0], context);
1718-
collide_block(undefined, dir, o1$3);
1719-
return /* tuple */[
1720-
spawned_item,
1721-
updated_block
1722-
];
17231729
break;
17241730

17251731
}

0 commit comments

Comments
 (0)