Skip to content

Commit 59057cc

Browse files
committed
Fix Pervasives.max
1 parent 1d8560f commit 59057cc

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

compiler/ml/translcore.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ let comparisons_table =
164164
objcomp = Pobjmax;
165165
intcomp = Pintmax;
166166
boolcomp = Pboolmax;
167-
floatcomp = Pboolmax;
167+
floatcomp = Pfloatmax;
168168
stringcomp = Pstringmax;
169169
bigintcomp = Pbigintmax;
170170
simplify_constant_constructor = false;
@@ -215,7 +215,7 @@ let comparisons_table =
215215
objcomp = Pobjmax;
216216
intcomp = Pintmax;
217217
boolcomp = Pboolmax;
218-
floatcomp = Pboolmax;
218+
floatcomp = Pfloatmax;
219219
stringcomp = Pstringmax;
220220
bigintcomp = Pbigintmax;
221221
simplify_constant_constructor = false;
@@ -387,7 +387,7 @@ let primitives_table =
387387
(* Compiler internals, never expose to ReScript files *)
388388
("#raw_expr", Pjs_raw_expr);
389389
("#raw_stmt", Pjs_raw_stmt);
390-
(* FIXME: Core compatibility *)
390+
(* FIXME: Core compatibility. Prefer starting with % *)
391391
("#null", Pnull);
392392
("#undefined", Pundefined);
393393
("#typeof", Ptypeof);

tests/tests/src/mario_game.mjs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import * as Belt_List from "rescript/lib/es6/Belt_List.js";
44
import * as Pervasives from "rescript/lib/es6/Pervasives.js";
55
import * as Primitive_int from "rescript/lib/es6/Primitive_int.js";
6-
import * as Primitive_bool from "rescript/lib/es6/Primitive_bool.js";
76
import * as Primitive_float from "rescript/lib/es6/Primitive_float.js";
87
import * as Primitive_object from "rescript/lib/es6/Primitive_object.js";
98
import * as Primitive_option from "rescript/lib/es6/Primitive_option.js";
@@ -979,7 +978,7 @@ function update_player(player, keys, context) {
979978
if (!player.jumping && player.grounded) {
980979
player.jumping = true;
981980
player.grounded = false;
982-
player.vel.y = Primitive_bool.max(player.vel.y - (5.7 + Math.abs(player.vel.x) * 0.25), -6);
981+
player.vel.y = Primitive_float.max(player.vel.y - (5.7 + Math.abs(player.vel.x) * 0.25), -6);
983982
return;
984983
} else {
985984
return;
@@ -1531,7 +1530,7 @@ function make$3(param, param$1) {
15311530

15321531
function calc_viewport_point(cc, vc, mc) {
15331532
let vc_half = vc / 2;
1534-
return Primitive_float.min(Primitive_bool.max(cc - vc_half, 0), Primitive_float.min(mc - vc, Math.abs(cc - vc_half)));
1533+
return Primitive_float.min(Primitive_float.max(cc - vc_half, 0), Primitive_float.min(mc - vc, Math.abs(cc - vc_half)));
15351534
}
15361535

15371536
function in_viewport(v, pos) {

tests/tests/src/test_pervasive.mjs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,20 @@ function a18(prim0, prim1) {
189189
return Math.pow(prim0, prim1);
190190
}
191191

192+
if ((
193+
1 > 2 ? 1 : 2
194+
) !== 2) {
195+
throw {
196+
RE_EXN_ID: "Assert_failure",
197+
_1: [
198+
"test_pervasive.res",
199+
28,
200+
0
201+
],
202+
Error: new Error()
203+
};
204+
}
205+
192206
let f = Pervasives.$at;
193207

194208
export {
@@ -214,4 +228,4 @@ export {
214228
a17,
215229
a18,
216230
}
217-
/* No side effect */
231+
/* Not a pure module */

tests/tests/src/test_pervasive.res

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ let a15 = log
2424
let a16 = log10
2525
let a17 = log1p
2626
let a18 = \"**"
27+
28+
assert(max(1., 2.) === 2.)
29+
2730
/* local variables: */
2831
/* compile-command: "ocamlc -dlambda -c test_pervasive.ml" */
2932
/* end: */

0 commit comments

Comments
 (0)