Skip to content

Commit 3bf39e3

Browse files
committed
fix
1 parent 8b12e8e commit 3bf39e3

18 files changed

+762
-582
lines changed

compiler/lib/generate.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,6 @@ let remove_unused_tail_args ctx exact trampolined args =
10571057
else args
10581058

10591059
let is_int = function
1060-
| J.ENum n -> J.Num.is_int n
10611060
| J.EBin ((J.Bor | J.Lsr), _, _) -> true
10621061
| _ -> false
10631062

compiler/tests-compiler/compact.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let rec f x y z =
4242
function(a, b, c){
4343
var f = a, e = b, d = c;
4444
for(;;){
45-
if(0 === f && 0 === e && 0 === d) return 1;
45+
if(Object.is(0, f) && Object.is(0, e) && Object.is(0, d)) return 1;
4646
var g = (d + f | 0) + e | 0;
4747
f = f + d | 0;
4848
e = e - d | 0;

compiler/tests-compiler/effects_toplevel.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ let%expect_test "test-compiler/lib-effects/test1.ml" =
8181
dummy,
8282
function(_c_){
8383
var _d_ = i + 1 | 0;
84-
if(5 !== i) return caml_cps_exact_call1(_b_, _d_);
84+
if(! Object.is(5, i)) return caml_cps_exact_call1(_b_, _d_);
8585
caml_callback(g, [dummy]);
8686
var Test = [0];
8787
runtime.caml_register_global(2, Test, "Test");

compiler/tests-compiler/es6.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ let rec odd n' = function
5959
(a, b)=>{
6060
var d = a, c = b;
6161
for(;;){
62-
if(0 === c) return [0, d, 0];
63-
if(1 === c) return [0, d, 1];
62+
if(Object.is(0, c)) return [0, d, 0];
63+
if(Object.is(1, c)) return [0, d, 1];
6464
[c, d] = [(d - 1 | 0) - 1 | 0, (c - 1 | 0) - 1 | 0];
6565
}}],
6666
"Test");
@@ -80,8 +80,8 @@ let rec odd n' = function
8080
function(a, b){
8181
var d = a, c = b;
8282
for(;;){
83-
if(0 === c) return [0, d, 0];
84-
if(1 === c) return [0, d, 1];
83+
if(Object.is(0, c)) return [0, d, 0];
84+
if(Object.is(1, c)) return [0, d, 1];
8585
var e = (d - 1 | 0) - 1 | 0;
8686
d = (c - 1 | 0) - 1 | 0;
8787
c = e;

compiler/tests-compiler/gh1007.ml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ let () = M.myfun M.x
162162
next = x$0[1],
163163
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];
@@ -244,7 +244,7 @@ let () = M.myfun M.x
244244
},
245245
rev_sort =
246246
function(n, l){
247-
if(2 === n){
247+
if(Object.is(2, n)){
248248
if(l){
249249
var match = l[2];
250250
if(match){
@@ -260,7 +260,7 @@ let () = M.myfun M.x
260260
}
261261
}
262262
}
263-
else if(3 === n && l){
263+
else if(Object.is(3, n) && l){
264264
var _b_ = l[2];
265265
if(_b_){
266266
var match$2 = _b_[2];
@@ -401,7 +401,7 @@ let () = M.run ()
401401
let odd$0 = odd, even$0 = even;
402402
if(even(i)) caml_call1(Stdlib[42], cst);
403403
var _a_ = i + 1 | 0;
404-
if(4 === i) return 0;
404+
if(Object.is(4, i)) return 0;
405405
i = _a_;
406406
}
407407
}
@@ -507,7 +507,7 @@ let () = M.run ()
507507
let odd$0 = odd, even$0 = even;
508508
if(even(i)) caml_call1(Stdlib[42], cst);
509509
var _c_ = i + 1 | 0;
510-
if(4 === i) break;
510+
if(Object.is(4, i)) break;
511511
i = _c_;
512512
}
513513
return caml_call2
@@ -638,7 +638,7 @@ let () = M.run ()
638638
param$0 = f(0);
639639
}
640640
var _e_ = i + 1 | 0;
641-
if(4 === i) break;
641+
if(Object.is(4, i)) break;
642642
i = _e_;
643643
}
644644
return caml_call2

compiler/tests-compiler/gh1320.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ let () = myfun ()
5050
var
5151
f =
5252
function(x){
53-
return 0 === x ? 1 : runtime.caml_mul(i$0, app(g$0, x - 1 | 0));
53+
return Object.is(0, x) ? 1 : runtime.caml_mul(i$0, app(g$0, x - 1 | 0));
5454
},
5555
g = function(x){return app(f$0, x);};
5656
let f$0 = f, g$0 = g;
5757
var _c_ = app(f, i);
5858
caml_call2(Stdlib_Printf[3], _a_, _c_);
5959
var _b_ = i + 1 | 0;
60-
if(4 === i) return 0;
60+
if(Object.is(4, i)) return 0;
6161
i = _b_;
6262
}
6363
}

compiler/tests-compiler/gh1559.ml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,13 @@ let () = my_ref := 2
9494
let t$1 = t;
9595
var
9696
this_will_be_undefined =
97-
function(param){var _c_ = 1 === t$1[1] ? 1 : 0; return _c_ ? 1 : 2;},
97+
function(param){
98+
var _c_ = Object.is(1, t$1[1]) ? 1 : 0;
99+
return _c_ ? 1 : 2;
100+
},
98101
i = t[1];
99-
if(0 === i){var _a_ = this_will_be_undefined(0); break a;}
100-
if(1 === i) break;
102+
if(Object.is(0, i)){var _a_ = this_will_be_undefined(0); break a;}
103+
if(Object.is(1, i)) break;
101104
t = t$0;
102105
}
103106
var
@@ -202,10 +205,13 @@ let () = my_ref := 2
202205
let t$1 = t;
203206
var
204207
this_will_be_undefined =
205-
function(param){var _e_ = 1 === t$1[1] ? 1 : 0; return _e_ ? 1 : 2;},
208+
function(param){
209+
var _e_ = Object.is(1, t$1[1]) ? 1 : 0;
210+
return _e_ ? 1 : 2;
211+
},
206212
i = t[1];
207-
if(0 === i) break;
208-
if(1 === i) break b;
213+
if(Object.is(0, i)) break;
214+
if(Object.is(1, i)) break b;
209215
t = t$0;
210216
}
211217
var

compiler/tests-compiler/gh747.ml

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

compiler/tests-compiler/global_deadcode.ml

Lines changed: 2 additions & 2 deletions
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);
@@ -83,7 +83,7 @@ let%expect_test "Eliminates unused functions from functor" =
8383
v = param$0[2],
8484
l = param$0[1],
8585
c = caml_call2(Ord[1], x, v);
86-
if(0 === c) return v;
86+
if(Object.is(0, c)) return v;
8787
var r$0 = 0 <= c ? r : l;
8888
param$0 = r$0;
8989
}

compiler/tests-compiler/lazy.ml

Lines changed: 3 additions & 3 deletions
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)