Skip to content

Commit 32a79e3

Browse files
committed
fix
1 parent 683da36 commit 32a79e3

File tree

10 files changed

+277
-369
lines changed

10 files changed

+277
-369
lines changed

compiler/lib/generate.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,7 @@ let throw_statement ctx cx k loc =
10171017
]
10181018

10191019
let is_int = function
1020+
| J.ENum n -> J.Num.is_int n && not (J.Num.is_zero n)
10201021
| J.EBin ((J.Bor | J.Lsr), _, _) -> true
10211022
| _ -> false
10221023

compiler/tests-compiler/effects_toplevel.ml

Lines changed: 1 addition & 1 deletion
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(! Object.is(5, i)) return caml_cps_exact_call1(_c_, _e_);
88+
if(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

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
rev_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];
@@ -240,7 +240,7 @@ let () = M.myfun M.x
240240
},
241241
sort =
242242
function(n, l){
243-
if(Object.is(2, n)){
243+
if(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(Object.is(3, n) && l){
259+
else if(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(Object.is(4, i)) return 0;
393+
if(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(Object.is(4, i)){
502+
if(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(Object.is(4, i)){
634+
if(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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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(Object.is(4, i)) return 0;
64+
if(4 === i) return 0;
6565
var i = _c_;
6666
}
6767
}

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
@@ -87,20 +87,20 @@ let rec fun_with_loop acc = function
8787
return caml_call1
8888
(list_rev, caml_call1(list_rev, caml_call1(list_rev, acc$0)));
8989
var x = param$0[1];
90-
if(Object.is(1, x) && ! param$0[2]){
90+
if(1 === x && ! param$0[2]){
9191
var a$0 = [0, acc$0], i$0 = 0;
9292
for(;;){
9393
a$0[1] = [0, 1, a$0[1]];
9494
var _b_ = i$0 + 1 | 0;
95-
if(Object.is(10, i$0)) return a$0[1];
95+
if(10 === i$0) return a$0[1];
9696
var i$0 = _b_;
9797
}
9898
}
9999
var xs = param$0[2], a = [0, acc$0], i = 0;
100100
for(;;){
101101
a[1] = [0, 1, a[1]];
102102
var _a_ = i + 1 | 0;
103-
if(Object.is(10, i)) break;
103+
if(10 === i) break;
104104
var i = _a_;
105105
}
106106
var acc$1 = [0, x, a[1]], acc$0 = acc$1, param$0 = xs;
@@ -134,11 +134,11 @@ let for_for_while () =
134134
for(;;){
135135
for(;;){if(10 <= runtime.caml_mul(k, j)) break; id[1]++;}
136136
var _b_ = j + 1 | 0;
137-
if(Object.is(10, j)) break;
137+
if(10 === j) break;
138138
var j = _b_;
139139
}
140140
var _a_ = k + 1 | 0;
141-
if(Object.is(10, k)) return 0;
141+
if(10 === k) return 0;
142142
var k = _a_;
143143
}
144144
}
@@ -175,11 +175,11 @@ let for_for_while () =
175175
id[1]++;
176176
}
177177
var _b_ = j + 1 | 0;
178-
if(Object.is(10, j)) break;
178+
if(10 === j) break;
179179
var j = _b_;
180180
}
181181
var _a_ = k + 1 | 0;
182-
if(Object.is(10, k)) return 0;
182+
if(10 === k) return 0;
183183
var k = _a_;
184184
}
185185
}
@@ -311,7 +311,7 @@ in loop x
311311
var x$1 = x;
312312
for(;;){
313313
if(Object.is(0, x$1)) return 1;
314-
if(Object.is(1, x$1)) break;
314+
if(1 === x$1) break;
315315
var x$2 = x$1 + 1 | 0, x$1 = x$2;
316316
}
317317
var x$0 = 2;
@@ -435,12 +435,12 @@ let add_substitute =
435435
var lim$1 = caml_ml_string_length(s), previous = 32, i$4 = 0;
436436
for(;;){
437437
if(i$4 >= lim$1){
438-
var _b_ = Object.is(92, previous) ? 1 : 0;
438+
var _b_ = 92 === previous ? 1 : 0;
439439
return _b_ ? caml_call2(add_char, b, previous) : _b_;
440440
}
441441
var previous$0 = caml_string_get(s, i$4);
442-
if(Object.is(36, previous$0))
443-
if(Object.is(92, previous)){
442+
if(36 === previous$0)
443+
if(92 === previous){
444444
caml_call2(add_char, b, previous$0);
445445
var i$5 = i$4 + 1 | 0, previous = 32, i$4 = i$5;
446446
}
@@ -450,7 +450,7 @@ let add_substitute =
450450
var opening = caml_string_get(s, start$0);
451451
a:
452452
{
453-
if(! Object.is(40, opening) && ! Object.is(123, opening)){
453+
if(40 !== opening && 123 !== opening){
454454
var start = start$0 + 1 | 0, lim$0 = caml_ml_string_length(s);
455455
b:
456456
{
@@ -466,7 +466,7 @@ let add_substitute =
466466
if(97 <= match){
467467
if(123 <= match) break d;
468468
}
469-
else if(! Object.is(95, match)) break d;
469+
else if(95 !== match) break d;
470470
}
471471
else if(58 <= match){
472472
if(65 > match) break;
@@ -486,10 +486,10 @@ let add_substitute =
486486
break a;
487487
}
488488
var new_start = start$0 + 1 | 0, k$2 = 0;
489-
if(Object.is(40, opening))
489+
if(40 === opening)
490490
var closing = 41;
491491
else{
492-
if(! Object.is(123, opening))
492+
if(123 !== opening)
493493
throw caml_maybe_attach_backtrace([0, Assert_failure, _a_], 1);
494494
var closing = 125;
495495
}
@@ -515,12 +515,12 @@ let add_substitute =
515515
caml_call2(add_string, b, caml_call1(f, ident));
516516
var previous = 32, i$4 = next_i;
517517
}
518-
else if(Object.is(92, previous)){
518+
else if(92 === previous){
519519
caml_call2(add_char, b, 92);
520520
caml_call2(add_char, b, previous$0);
521521
var i$6 = i$4 + 1 | 0, previous = 32, i$4 = i$6;
522522
}
523-
else if(Object.is(92, previous$0))
523+
else if(92 === previous$0)
524524
var i$7 = i$4 + 1 | 0, previous = previous$0, i$4 = i$7;
525525
else{
526526
caml_call2(add_char, b, previous$0);

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
closures =
125125
function(i){
126126
function f(counter, n){
127-
if(Object.is(- 1, n)){
127+
if(- 1 === n){
128128
var _j_ = - 2;
129129
if(counter >= 50) return caml_trampoline_return(g, [0, _j_]);
130130
var counter$1 = counter + 1 | 0;
@@ -137,7 +137,7 @@ let%expect_test _ =
137137
return g(counter$0, _k_);
138138
}
139139
function g(counter, n){
140-
if(Object.is(- 1, n)){
140+
if(- 1 === n){
141141
var _h_ = - 2;
142142
if(counter >= 50) return caml_trampoline_return(f, [0, _h_]);
143143
var counter$1 = counter + 1 | 0;
@@ -162,7 +162,7 @@ let%expect_test _ =
162162
indirect[1] =
163163
[0, function(i, f){return function(param){return f(i);};}(i, f), _f_];
164164
var _g_ = i + 1 | 0;
165-
if(Object.is(3, i)){
165+
if(3 === i){
166166
var
167167
_d_ = indirect[1],
168168
indirect$0 =

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)