Skip to content

Commit 683da36

Browse files
committed
fix
1 parent bbb0d67 commit 683da36

14 files changed

+739
-563
lines changed

compiler/lib/generate.ml

-1
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,6 @@ let throw_statement ctx cx k loc =
10171017
]
10181018

10191019
let is_int = function
1020-
| J.ENum n -> J.Num.is_int n
10211020
| J.EBin ((J.Bor | J.Lsr), _, _) -> true
10221021
| _ -> false
10231022

compiler/tests-compiler/effects_toplevel.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ let%expect_test "test-compiler/lib-effects/test1.ml" =
8585
undef,
8686
function(_d_){
8787
var _e_ = i + 1 | 0;
88-
if(5 !== i) return caml_cps_exact_call1(_c_, _e_);
88+
if(! Object.is(5, i)) return caml_cps_exact_call1(_c_, _e_);
8989
caml_callback(g, [undef]);
9090
var Test = [0];
9191
runtime.caml_register_global(2, Test, "Test");

compiler/tests-compiler/gh1007.ml

+7-7
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ let () = M.myfun M.x
162162
next = x$0[1],
163163
rev_sort =
164164
function(n, l){
165-
if(2 === n){
165+
if(Object.is(2, n)){
166166
if(l){
167167
var match = l[2];
168168
if(match){
@@ -178,7 +178,7 @@ let () = M.myfun M.x
178178
}
179179
}
180180
}
181-
else if(3 === n && l){
181+
else if(Object.is(3, n) && l){
182182
var _d_ = l[2];
183183
if(_d_){
184184
var match$2 = _d_[2];
@@ -240,7 +240,7 @@ let () = M.myfun M.x
240240
},
241241
sort =
242242
function(n, l){
243-
if(2 === n){
243+
if(Object.is(2, n)){
244244
if(l){
245245
var match = l[2];
246246
if(match){
@@ -256,7 +256,7 @@ let () = M.myfun M.x
256256
}
257257
}
258258
}
259-
else if(3 === n && l){
259+
else if(Object.is(3, n) && l){
260260
var _b_ = l[2];
261261
if(_b_){
262262
var match$2 = _b_[2];
@@ -390,7 +390,7 @@ let () = M.run ()
390390
};
391391
if(even(i)) caml_call1(Stdlib[42], cst);
392392
var _a_ = i + 1 | 0;
393-
if(4 === i) return 0;
393+
if(Object.is(4, i)) return 0;
394394
var i = _a_;
395395
}
396396
}
@@ -499,7 +499,7 @@ let () = M.run ()
499499
even = closures$0[1];
500500
if(even(i)) caml_call1(Stdlib[42], cst);
501501
var _e_ = i + 1 | 0;
502-
if(4 === i){
502+
if(Object.is(4, i)){
503503
var _d_ = caml_call1(list_rev, delayed[1]);
504504
return caml_call2(list_iter, function(f){return caml_call1(f, 0);}, _d_);
505505
}
@@ -631,7 +631,7 @@ let () = M.run ()
631631
var f = param$0[2], param$0 = f(0);
632632
}
633633
var _g_ = i + 1 | 0;
634-
if(4 === i){
634+
if(Object.is(4, i)){
635635
var _f_ = caml_call1(list_rev, delayed[1]);
636636
return caml_call2(list_iter, function(f){return caml_call1(f, 0);}, _f_);
637637
}

compiler/tests-compiler/gh1320.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ let () = myfun ()
5151
function(i){
5252
function g(x){return app(f, x);}
5353
function f(x){
54-
return 0 === x ? 1 : runtime.caml_mul(i, app(g, x - 1 | 0));
54+
return Object.is(0, x) ? 1 : runtime.caml_mul(i, app(g, x - 1 | 0));
5555
}
5656
var block = [0, g, f];
5757
return block;
@@ -61,7 +61,7 @@ let () = myfun ()
6161
_b_ = g(i);
6262
caml_call2(Stdlib_Printf[3], _a_, _b_);
6363
var _c_ = i + 1 | 0;
64-
if(4 === i) return 0;
64+
if(Object.is(4, i)) return 0;
6565
var i = _c_;
6666
}
6767
}

compiler/tests-compiler/gh747.ml

+86-83
Original file line numberDiff line numberDiff line change
@@ -316,86 +316,89 @@ end
316316
91: function format_backtrace_slot(pos, slot){
317317
92: function info(is_raise){
318318
93: /*<<test.ml:46:4>>*/ return is_raise
319-
94: ? 0 === pos ? cst_Raised_at : cst_Re_raised_at
320-
95: : 0 === pos ? cst_Raised_by_primitive_operat : cst_Called_from;
321-
96: /*<<test.ml:49:75>>*/ }
322-
97: /*<<test.ml:51:2>>*/ if(0 === slot[0]){
323-
98: /*<<test.ml:59:14>>*/ var
324-
99: _h_ = slot[5],
325-
100: _i_ = slot[4],
326-
101: _j_ = slot[3],
327-
102: _k_ = slot[6] ? cst_inlined : cst,
328-
103: _l_ = slot[2],
329-
104: _m_ = slot[7],
330-
105: /*<<test.ml:59:14>>*/ _n_ = info(slot[1]);
331-
106: /*<<test.ml:58:6>>*/ return [0,
332-
107: /*<<test.ml:58:11>>*/ caml_call8
333-
108: (Stdlib_Printf[4], _a_, _n_, _m_, _l_, _k_, _j_, _i_, _h_)];
334-
109: }
335-
110: if(slot[1]) /*<<test.ml:54:50>>*/ return 0;
336-
111: /*<<test.ml:56:51>>*/ /*<<test.ml:56:51>>*/ var _o_ = info(0);
337-
112: /*<<test.ml:56:8>>*/ return [0,
338-
113: /*<<test.ml:56:13>>*/ caml_call2(Stdlib_Printf[4], _b_, _o_)];
339-
114: /*<<test.ml:61:52>>*/ }
340-
115: function print_exception_backtrace(outchan, backtrace){
341-
116: /*<<test.ml:64:2>>*/ if(! backtrace)
342-
117: /*<<test.ml:66:6>>*/ return /*<<test.ml:66:6>>*/ caml_call2
343-
118: (Stdlib_Printf[1], outchan, _d_);
344-
119: var a = backtrace[1], _f_ = a.length - 1 - 1 | 0, _e_ = 0;
345-
120: if(_f_ >= 0){
346-
121: var i = _e_;
347-
122: for(;;){
348-
123: /*<<test.ml:70:14>>*/ /*<<test.ml:70:14>>*/ var
349-
124: match = format_backtrace_slot(i, runtime.caml_check_bound(a, i)[1 + i]);
350-
125: if(match){
351-
126: var str = match[1];
352-
127: /*<<test.ml:72:24>>*/ /*<<test.ml:72:24>>*/ caml_call3
353-
128: (Stdlib_Printf[1], outchan, _c_, str);
354-
129: }
355-
130: /*<<test.ml:69:6>>*/ /*<<test.ml:69:6>>*/ var _g_ = i + 1 | 0;
356-
131: if(Object.is(_f_, i)) break;
357-
132: var i = _g_;
358-
133: }
359-
134: }
360-
135: return 0;
361-
136: /*<<test.ml:73:10>>*/ }
362-
137: function compare(left, right, e1, e2){
363-
138: /*<<test.ml:77:35>>*/ if(0 === e1[0]){
364-
139: var v1 = e1[1];
365-
140: if(0 !== e2[0]) /*<<test.ml:80:23>>*/ return -1;
366-
141: var v2 = e2[1];
367-
142: /*<<test.ml:78:24>>*/ return /*<<test.ml:78:24>>*/ caml_call2
368-
143: (left, v1, v2);
369-
144: }
370-
145: var v1$0 = e1[1];
371-
146: if(0 === e2[0]) /*<<test.ml:81:23>>*/ return 1;
372-
147: var v2$0 = e2[1];
373-
148: /*<<test.ml:79:26>>*/ return /*<<test.ml:79:26>>*/ caml_call2
374-
149: (right, v1$0, v2$0);
375-
150: /*<<test.ml:81:24>>*/ }
376-
151: /*<<test.ml:75:16>>*/ var
377-
152: /*<<test.ml:75:16>>*/ Either = [0, compare],
378-
153: Test =
379-
154: [0,
380-
155: executable_name,
381-
156: os_type,
382-
157: backend_type,
383-
158: big_endian,
384-
159: word_size,
385-
160: int_size,
386-
161: unix,
387-
162: win32,
388-
163: cygwin,
389-
164: max_array_length,
390-
165: max_floatarray_length,
391-
166: max_string_length,
392-
167: Unhandled,
393-
168: format_backtrace_slot,
394-
169: print_exception_backtrace,
395-
170: Either];
396-
171: runtime.caml_register_global(12, Test, "Test");
397-
172: return;
398-
173: /*<<?>>*/ }
399-
174: (globalThis));
400-
175:
401-
176: //# sourceMappingURL=test.map |}]
319+
94: ? Object.is(0, pos) ? cst_Raised_at : cst_Re_raised_at
320+
95: : Object.is
321+
96: (0, pos)
322+
97: ? cst_Raised_by_primitive_operat
323+
98: : cst_Called_from;
324+
99: /*<<test.ml:49:75>>*/ }
325+
100: /*<<test.ml:51:2>>*/ if(0 === slot[0]){
326+
101: /*<<test.ml:59:14>>*/ var
327+
102: _h_ = slot[5],
328+
103: _i_ = slot[4],
329+
104: _j_ = slot[3],
330+
105: _k_ = slot[6] ? cst_inlined : cst,
331+
106: _l_ = slot[2],
332+
107: _m_ = slot[7],
333+
108: /*<<test.ml:59:14>>*/ _n_ = info(slot[1]);
334+
109: /*<<test.ml:58:6>>*/ return [0,
335+
110: /*<<test.ml:58:11>>*/ caml_call8
336+
111: (Stdlib_Printf[4], _a_, _n_, _m_, _l_, _k_, _j_, _i_, _h_)];
337+
112: }
338+
113: if(slot[1]) /*<<test.ml:54:50>>*/ return 0;
339+
114: /*<<test.ml:56:51>>*/ /*<<test.ml:56:51>>*/ var _o_ = info(0);
340+
115: /*<<test.ml:56:8>>*/ return [0,
341+
116: /*<<test.ml:56:13>>*/ caml_call2(Stdlib_Printf[4], _b_, _o_)];
342+
117: /*<<test.ml:61:52>>*/ }
343+
118: function print_exception_backtrace(outchan, backtrace){
344+
119: /*<<test.ml:64:2>>*/ if(! backtrace)
345+
120: /*<<test.ml:66:6>>*/ return /*<<test.ml:66:6>>*/ caml_call2
346+
121: (Stdlib_Printf[1], outchan, _d_);
347+
122: var a = backtrace[1], _f_ = a.length - 1 - 1 | 0, _e_ = 0;
348+
123: if(_f_ >= 0){
349+
124: var i = _e_;
350+
125: for(;;){
351+
126: /*<<test.ml:70:14>>*/ /*<<test.ml:70:14>>*/ var
352+
127: match = format_backtrace_slot(i, runtime.caml_check_bound(a, i)[1 + i]);
353+
128: if(match){
354+
129: var str = match[1];
355+
130: /*<<test.ml:72:24>>*/ /*<<test.ml:72:24>>*/ caml_call3
356+
131: (Stdlib_Printf[1], outchan, _c_, str);
357+
132: }
358+
133: /*<<test.ml:69:6>>*/ /*<<test.ml:69:6>>*/ var _g_ = i + 1 | 0;
359+
134: if(Object.is(_f_, i)) break;
360+
135: var i = _g_;
361+
136: }
362+
137: }
363+
138: return 0;
364+
139: /*<<test.ml:73:10>>*/ }
365+
140: function compare(left, right, e1, e2){
366+
141: /*<<test.ml:77:35>>*/ if(0 === e1[0]){
367+
142: var v1 = e1[1];
368+
143: if(0 !== e2[0]) /*<<test.ml:80:23>>*/ return -1;
369+
144: var v2 = e2[1];
370+
145: /*<<test.ml:78:24>>*/ return /*<<test.ml:78:24>>*/ caml_call2
371+
146: (left, v1, v2);
372+
147: }
373+
148: var v1$0 = e1[1];
374+
149: if(0 === e2[0]) /*<<test.ml:81:23>>*/ return 1;
375+
150: var v2$0 = e2[1];
376+
151: /*<<test.ml:79:26>>*/ return /*<<test.ml:79:26>>*/ caml_call2
377+
152: (right, v1$0, v2$0);
378+
153: /*<<test.ml:81:24>>*/ }
379+
154: /*<<test.ml:75:16>>*/ var
380+
155: /*<<test.ml:75:16>>*/ Either = [0, compare],
381+
156: Test =
382+
157: [0,
383+
158: executable_name,
384+
159: os_type,
385+
160: backend_type,
386+
161: big_endian,
387+
162: word_size,
388+
163: int_size,
389+
164: unix,
390+
165: win32,
391+
166: cygwin,
392+
167: max_array_length,
393+
168: max_floatarray_length,
394+
169: max_string_length,
395+
170: Unhandled,
396+
171: format_backtrace_slot,
397+
172: print_exception_backtrace,
398+
173: Either];
399+
174: runtime.caml_register_global(12, Test, "Test");
400+
175: return;
401+
176: /*<<?>>*/ }
402+
177: (globalThis));
403+
178:
404+
179: //# sourceMappingURL=test.map |}]

compiler/tests-compiler/global_deadcode.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ let%expect_test "Eliminates unused functions from functor" =
6868
function add(x, t){
6969
if(! t) return [0, 0, x, 0, 1];
7070
var r = t[3], v = t[2], l = t[1], c = caml_call2(Ord[1], x, v);
71-
if(0 === c) return t;
71+
if(Object.is(0, c)) return t;
7272
if(0 <= c){var rr = add(x, r); return Object.is(r, rr) ? t : bal(l, v, rr);}
7373
var ll = add(x, l);
7474
return Object.is(l, ll) ? t : bal(ll, v, r);
@@ -84,7 +84,7 @@ let%expect_test "Eliminates unused functions from functor" =
8484
v = param$0[2],
8585
l = param$0[1],
8686
c = caml_call2(Ord[1], x, v);
87-
if(0 === c) return v;
87+
if(Object.is(0, c)) return v;
8888
var r$0 = 0 <= c ? r : l, param$0 = r$0;
8989
}
9090
}

compiler/tests-compiler/lazy.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ let%expect_test "static eval of string get" =
3434
[%expect
3535
{|
3636
function do_the_lazy_rec(n){
37-
if(0 === n) return 0;
37+
if(Object.is(0, n)) return 0;
3838
var _b_ = do_the_lazy_rec(n - 1 | 0), _c_ = runtime.caml_obj_tag(lz);
3939
a:
40-
if(250 === _c_)
40+
if(Object.is(250, _c_))
4141
var _d_ = lz[1];
4242
else{
43-
if(246 !== _c_ && 244 !== _c_){var _d_ = lz; break a;}
43+
if(! Object.is(246, _c_) && ! Object.is(244, _c_)){var _d_ = lz; break a;}
4444
var _d_ = caml_call1(CamlinternalLazy[2], lz);
4545
}
4646
return [0, _d_, _b_];

0 commit comments

Comments
 (0)