Skip to content

Commit c2aa635

Browse files
OlivierNicolehhugo
authored andcommitted
Fix runtime annotations
Some comparison functions may raise on functional values.
1 parent 5738f8a commit c2aa635

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

runtime/js/compare.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ function caml_compare_val(a, b, total) {
251251
b = b[i];
252252
}
253253
}
254+
255+
// May raise
254256
//Provides: caml_compare (const, const)
255257
//Requires: caml_compare_val
256258
function caml_compare(a, b) {
@@ -265,32 +267,44 @@ function caml_int_compare(a, b) {
265267
if (a === b) return 0;
266268
return 1;
267269
}
268-
//Provides: caml_equal mutable (const, const)
270+
271+
// May raise
272+
//Provides: caml_equal (const, const)
269273
//Requires: caml_compare_val
270274
function caml_equal(x, y) {
271275
return +(caml_compare_val(x, y, false) === 0);
272276
}
273-
//Provides: caml_notequal mutable (const, const)
277+
278+
// May raise
279+
//Provides: caml_notequal (const, const)
274280
//Requires: caml_compare_val
275281
function caml_notequal(x, y) {
276282
return +(caml_compare_val(x, y, false) !== 0);
277283
}
278-
//Provides: caml_greaterequal mutable (const, const)
284+
285+
// May raise
286+
//Provides: caml_greaterequal (const, const)
279287
//Requires: caml_compare_val
280288
function caml_greaterequal(x, y) {
281289
return +(caml_compare_val(x, y, false) >= 0);
282290
}
283-
//Provides: caml_greaterthan mutable (const, const)
291+
292+
// May raise
293+
//Provides: caml_greaterthan (const, const)
284294
//Requires: caml_compare_val
285295
function caml_greaterthan(x, y) {
286296
return +(caml_compare_val(x, y, false) > 0);
287297
}
288-
//Provides: caml_lessequal mutable (const, const)
298+
299+
// May raise
300+
//Provides: caml_lessequal (const, const)
289301
//Requires: caml_compare_val
290302
function caml_lessequal(x, y) {
291303
return +(caml_compare_val(x, y, false) <= 0);
292304
}
293-
//Provides: caml_lessthan mutable (const, const)
305+
306+
// May raise
307+
//Provides: caml_lessthan (const, const)
294308
//Requires: caml_compare_val
295309
function caml_lessthan(x, y) {
296310
return +(caml_compare_val(x, y, false) < 0);

0 commit comments

Comments
 (0)