Skip to content

Commit bc5cfe6

Browse files
committed
fix
1 parent 3bf39e3 commit bc5cfe6

File tree

13 files changed

+286
-375
lines changed

13 files changed

+286
-375
lines changed

compiler/lib/generate.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,7 @@ 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 && not (J.Num.is_zero n)
10601061
| J.EBin ((J.Bor | J.Lsr), _, _) -> true
10611062
| _ -> false
10621063

compiler/tests-compiler/effects_toplevel.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,13 @@ let%expect_test "test-compiler/lib-effects/test1.ml" =
8181
dummy,
8282
function(_c_){
8383
var _d_ = i + 1 | 0;
84+
<<<<<<< HEAD
8485
if(! Object.is(5, i)) return caml_cps_exact_call1(_b_, _d_);
8586
caml_callback(g, [dummy]);
87+
=======
88+
if(5 !== i) return caml_cps_exact_call1(_b_, _d_);
89+
caml_callback(g, [undef]);
90+
>>>>>>> 21ff3c88d1 (fix)
8691
var Test = [0];
8792
runtime.caml_register_global(2, Test, "Test");
8893
});

compiler/tests-compiler/es6.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ let rec odd n' = function
6060
var d = a, c = b;
6161
for(;;){
6262
if(Object.is(0, c)) return [0, d, 0];
63-
if(Object.is(1, c)) return [0, d, 1];
63+
if(1 === c) return [0, d, 1];
6464
[c, d] = [(d - 1 | 0) - 1 | 0, (c - 1 | 0) - 1 | 0];
6565
}}],
6666
"Test");
@@ -81,7 +81,7 @@ let rec odd n' = function
8181
var d = a, c = b;
8282
for(;;){
8383
if(Object.is(0, c)) return [0, d, 0];
84-
if(Object.is(1, c)) return [0, d, 1];
84+
if(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(Object.is(2, n)){
165+
if(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(Object.is(3, n) && l){
181+
else if(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(Object.is(2, n)){
247+
if(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(Object.is(3, n) && l){
263+
else if(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(Object.is(4, i)) return 0;
404+
if(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(Object.is(4, i)) break;
510+
if(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(Object.is(4, i)) break;
641+
if(4 === i) break;
642642
i = _e_;
643643
}
644644
return caml_call2

compiler/tests-compiler/gh1320.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ let () = myfun ()
5757
var _c_ = app(f, i);
5858
caml_call2(Stdlib_Printf[3], _a_, _c_);
5959
var _b_ = i + 1 | 0;
60-
if(Object.is(4, i)) return 0;
60+
if(4 === i) return 0;
6161
i = _b_;
6262
}
6363
}

compiler/tests-compiler/gh1559.ml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,10 @@ let () = my_ref := 2
9494
let t$1 = t;
9595
var
9696
this_will_be_undefined =
97-
function(param){
98-
var _c_ = Object.is(1, t$1[1]) ? 1 : 0;
99-
return _c_ ? 1 : 2;
100-
},
97+
function(param){var _c_ = 1 === t$1[1] ? 1 : 0; return _c_ ? 1 : 2;},
10198
i = t[1];
10299
if(Object.is(0, i)){var _a_ = this_will_be_undefined(0); break a;}
103-
if(Object.is(1, i)) break;
100+
if(1 === i) break;
104101
t = t$0;
105102
}
106103
var
@@ -205,13 +202,10 @@ let () = my_ref := 2
205202
let t$1 = t;
206203
var
207204
this_will_be_undefined =
208-
function(param){
209-
var _e_ = Object.is(1, t$1[1]) ? 1 : 0;
210-
return _e_ ? 1 : 2;
211-
},
205+
function(param){var _e_ = 1 === t$1[1] ? 1 : 0; return _e_ ? 1 : 2;},
212206
i = t[1];
213207
if(Object.is(0, i)) break;
214-
if(Object.is(1, i)) break b;
208+
if(1 === i) break b;
215209
t = t$0;
216210
}
217211
var

compiler/tests-compiler/lazy.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ let%expect_test "static eval of string get" =
3737
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(Object.is(250, _c_))
40+
if(250 === _c_)
4141
var _d_ = lz[1];
4242
else{
43-
if(! Object.is(246, _c_) && ! Object.is(244, _c_)){var _d_ = lz; break a;}
43+
if(246 !== _c_ && 244 !== _c_){var _d_ = lz; break a;}
4444
var _d_ = caml_call1(CamlinternalLazy[2], lz);
4545
}
4646
return [0, _d_, _b_];

compiler/tests-compiler/loops.ml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,20 @@ let rec fun_with_loop acc = function
8484
return caml_call1
8585
(list_rev, caml_call1(list_rev, caml_call1(list_rev, acc$0)));
8686
var x = param$0[1];
87-
if(Object.is(1, x) && ! param$0[2]){
87+
if(1 === x && ! param$0[2]){
8888
var a$0 = [0, acc$0], i$0 = 0;
8989
for(;;){
9090
a$0[1] = [0, 1, a$0[1]];
9191
var _b_ = i$0 + 1 | 0;
92-
if(Object.is(10, i$0)) return a$0[1];
92+
if(10 === i$0) return a$0[1];
9393
i$0 = _b_;
9494
}
9595
}
9696
var xs = param$0[2], a = [0, acc$0], i = 0;
9797
for(;;){
9898
a[1] = [0, 1, a[1]];
9999
var _a_ = i + 1 | 0;
100-
if(Object.is(10, i)) break;
100+
if(10 === i) break;
101101
i = _a_;
102102
}
103103
var acc$1 = [0, x, a[1]];
@@ -133,11 +133,11 @@ let for_for_while () =
133133
for(;;){
134134
for(;;){if(10 <= runtime.caml_mul(k, j)) break; id[1]++;}
135135
var _b_ = j + 1 | 0;
136-
if(Object.is(10, j)) break;
136+
if(10 === j) break;
137137
j = _b_;
138138
}
139139
var _a_ = k + 1 | 0;
140-
if(Object.is(10, k)) return 0;
140+
if(10 === k) return 0;
141141
k = _a_;
142142
}
143143
}
@@ -174,11 +174,11 @@ let for_for_while () =
174174
id[1]++;
175175
}
176176
var _b_ = j + 1 | 0;
177-
if(Object.is(10, j)) break;
177+
if(10 === j) break;
178178
j = _b_;
179179
}
180180
var _a_ = k + 1 | 0;
181-
if(Object.is(10, k)) return 0;
181+
if(10 === k) return 0;
182182
k = _a_;
183183
}
184184
}
@@ -312,7 +312,7 @@ in loop x
312312
var x$1 = x;
313313
for(;;){
314314
if(Object.is(0, x$1)) return 1;
315-
if(Object.is(1, x$1)) break;
315+
if(1 === x$1) break;
316316
var x$2 = x$1 + 1 | 0;
317317
x$1 = x$2;
318318
}
@@ -437,12 +437,12 @@ let add_substitute =
437437
var lim$1 = caml_ml_string_length(s), previous = 32, i$4 = 0;
438438
for(;;){
439439
if(i$4 >= lim$1){
440-
var _b_ = Object.is(92, previous) ? 1 : 0;
440+
var _b_ = 92 === previous ? 1 : 0;
441441
return _b_ ? caml_call2(add_char, b, previous) : _b_;
442442
}
443443
var previous$0 = caml_string_get(s, i$4);
444-
if(Object.is(36, previous$0))
445-
if(Object.is(92, previous)){
444+
if(36 === previous$0)
445+
if(92 === previous){
446446
caml_call2(add_char, b, previous$0);
447447
var i$5 = i$4 + 1 | 0;
448448
previous = 32;
@@ -454,7 +454,7 @@ let add_substitute =
454454
var opening = caml_string_get(s, start$0);
455455
a:
456456
{
457-
if(! Object.is(40, opening) && ! Object.is(123, opening)){
457+
if(40 !== opening && 123 !== opening){
458458
var start = start$0 + 1 | 0, lim$0 = caml_ml_string_length(s);
459459
b:
460460
{
@@ -470,7 +470,7 @@ let add_substitute =
470470
if(97 <= match){
471471
if(123 <= match) break d;
472472
}
473-
else if(! Object.is(95, match)) break d;
473+
else if(95 !== match) break d;
474474
}
475475
else if(58 <= match){
476476
if(65 > match) break;
@@ -491,10 +491,10 @@ let add_substitute =
491491
break a;
492492
}
493493
var new_start = start$0 + 1 | 0, k$2 = 0;
494-
if(Object.is(40, opening))
494+
if(40 === opening)
495495
var closing = 41;
496496
else{
497-
if(! Object.is(123, opening))
497+
if(123 !== opening)
498498
throw caml_maybe_attach_backtrace([0, Assert_failure, _a_], 1);
499499
var closing = 125;
500500
}
@@ -525,14 +525,14 @@ let add_substitute =
525525
previous = 32;
526526
i$4 = next_i;
527527
}
528-
else if(Object.is(92, previous)){
528+
else if(92 === previous){
529529
caml_call2(add_char, b, 92);
530530
caml_call2(add_char, b, previous$0);
531531
var i$6 = i$4 + 1 | 0;
532532
previous = 32;
533533
i$4 = i$6;
534534
}
535-
else if(Object.is(92, previous$0)){
535+
else if(92 === previous$0){
536536
var i$7 = i$4 + 1 | 0;
537537
previous = previous$0;
538538
i$4 = i$7;

compiler/tests-compiler/match_with_exn.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ let fun2 () =
8080
var _d_ = caml_wrap_exception(_e_);
8181
if(! Object.is(_d_[1], A)) throw caml_maybe_attach_backtrace(_d_, 0);
8282
var i = _d_[2];
83-
if(! Object.is(2, i)) return i + 2 | 0;
83+
if(2 !== i) return i + 2 | 0;
8484
var i$0 = i;
8585
break a;
8686
}
@@ -98,7 +98,7 @@ let fun2 () =
9898
var _a_ = caml_wrap_exception(_c_);
9999
if(Object.is(_a_[1], A)){
100100
var _b_ = _a_[2];
101-
if(Object.is(2, _b_)){var i = _b_; break a;}
101+
if(2 === _b_){var i = _b_; break a;}
102102
}
103103
throw caml_maybe_attach_backtrace(_a_, 0);
104104
}

compiler/tests-compiler/mutable_closure.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ let%expect_test _ =
124124
var
125125
f$0 =
126126
function(counter, n){
127-
if(Object.is(- 1, n)){
127+
if(- 1 === n){
128128
var _f_ = - 2;
129129
if(counter >= 50) return caml_trampoline_return(g$0, [0, _f_]);
130130
var counter$1 = counter + 1 | 0;
@@ -139,7 +139,7 @@ let%expect_test _ =
139139
f = function(n){return caml_trampoline(f$1(0, n));},
140140
g =
141141
function(counter, n){
142-
if(Object.is(- 1, n)){
142+
if(- 1 === n){
143143
var _d_ = - 2;
144144
if(counter >= 50) return caml_trampoline_return(f$1, [0, _d_]);
145145
var counter$1 = counter + 1 | 0;
@@ -157,7 +157,7 @@ let%expect_test _ =
157157
let f$2 = f;
158158
indirect[1] = [0, function(param){return f$2(i$0);}, indirect[1]];
159159
var _c_ = i + 1 | 0;
160-
if(Object.is(3, i)) break;
160+
if(3 === i) break;
161161
i = _c_;
162162
}
163163
var

compiler/tests-compiler/side_effect.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ let%expect_test _ =
110110
>>> 0
111111
? caml_call1(Stdlib_Printf[2], _b_)
112112
: caml_call1(Stdlib_Printf[2], _c_);
113-
if(Object.is(1, i[1]))
113+
if(1 === i[1])
114114
log_success(0);
115115
else
116116
caml_call1(log_failure, cst_side_effect_computed_twice);

compiler/tests-compiler/variable_declaration_output.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ let%expect_test _ =
131131
if(_a_){
132132
_b_ = _a_[1];
133133
if(_b_){
134-
if(Object.is(2, _b_[1]) && ! param[2]) return 3;
134+
if(2 === _b_[1] && ! param[2]) return 3;
135135
}
136136
else if(! param[2]) return 2;
137137
}
@@ -153,7 +153,7 @@ let%expect_test _ =
153153
if(_a_){
154154
var _b_ = _a_[1];
155155
if(_b_){
156-
if(Object.is(2, _b_[1]) && ! param[2]) return 3;
156+
if(2 === _b_[1] && ! param[2]) return 3;
157157
}
158158
else if(! param[2]) return 2;
159159
}

0 commit comments

Comments
 (0)