Skip to content

Commit 98b17b0

Browse files
committed
Allow more general type for tags.
Compile is_tag to `!== "object"` instead of `=== "string"`.
1 parent 14331a6 commit 98b17b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2024
-2024
lines changed

jscomp/test/adt_optimize_test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function f4(param) {
6161
}
6262

6363
function f5(param) {
64-
if (typeof param === "string") {
64+
if (typeof param !== "object") {
6565
switch (param) {
6666
case "A" :
6767
return 1;
@@ -84,7 +84,7 @@ function f5(param) {
8484
}
8585

8686
function f6(param) {
87-
if (typeof param !== "string") {
87+
if (typeof param === "object") {
8888
return 1;
8989
}
9090
switch (param) {
@@ -98,7 +98,7 @@ function f6(param) {
9898
}
9999

100100
function f7(param) {
101-
if (typeof param === "string") {
101+
if (typeof param !== "object") {
102102
switch (param) {
103103
case "A" :
104104
return 1;
@@ -122,7 +122,7 @@ function f7(param) {
122122
}
123123

124124
function f8(param) {
125-
if (typeof param === "string") {
125+
if (typeof param !== "object") {
126126
switch (param) {
127127
case "T60" :
128128
case "T61" :
@@ -142,7 +142,7 @@ function f8(param) {
142142
}
143143

144144
function f9(param) {
145-
if (typeof param === "string") {
145+
if (typeof param !== "object") {
146146
if (param === "T63") {
147147
return 3;
148148
} else {
@@ -161,7 +161,7 @@ function f9(param) {
161161
}
162162

163163
function f10(param) {
164-
if (typeof param === "string") {
164+
if (typeof param !== "object") {
165165
switch (param) {
166166
case "T60" :
167167
return 0;
@@ -187,7 +187,7 @@ function f10(param) {
187187
}
188188

189189
function f11(x) {
190-
if (typeof x === "string") {
190+
if (typeof x !== "object") {
191191
return 2;
192192
}
193193
if (x.TAG === "D") {

jscomp/test/bal_set_mini.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
function height(param) {
5-
if (typeof param === "string") {
5+
if (typeof param !== "object") {
66
return 0;
77
} else {
88
return param._3;
@@ -24,15 +24,15 @@ function bal(l, v, r) {
2424
var hl = height(l);
2525
var hr = height(r);
2626
if (hl > (hr + 2 | 0)) {
27-
if (typeof l === "string") {
27+
if (typeof l !== "object") {
2828
return "Empty";
2929
}
3030
var lr = l._2;
3131
var lv = l._1;
3232
var ll = l._0;
3333
if (height(ll) >= height(lr)) {
3434
return create(ll, lv, create(lr, v, r));
35-
} else if (typeof lr === "string") {
35+
} else if (typeof lr !== "object") {
3636
return "Empty";
3737
} else {
3838
return create(create(ll, lv, lr._0), lr._1, create(lr._2, v, r));
@@ -46,15 +46,15 @@ function bal(l, v, r) {
4646
_3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0
4747
};
4848
}
49-
if (typeof r === "string") {
49+
if (typeof r !== "object") {
5050
return "Empty";
5151
}
5252
var rr = r._2;
5353
var rv = r._1;
5454
var rl = r._0;
5555
if (height(rr) >= height(rl)) {
5656
return create(create(l, v, rl), rv, rr);
57-
} else if (typeof rl === "string") {
57+
} else if (typeof rl !== "object") {
5858
return "Empty";
5959
} else {
6060
return create(create(l, v, rl._0), rl._1, create(rl._2, rv, rr));
@@ -72,7 +72,7 @@ function compare_int(x, y) {
7272
}
7373

7474
function add(x, t) {
75-
if (typeof t === "string") {
75+
if (typeof t !== "object") {
7676
return /* Node */{
7777
_0: "Empty",
7878
_1: x,
@@ -97,11 +97,11 @@ function min_elt(_def, _param) {
9797
while(true) {
9898
var param = _param;
9999
var def = _def;
100-
if (typeof param === "string") {
100+
if (typeof param !== "object") {
101101
return def;
102102
}
103103
var l = param._0;
104-
if (typeof l === "string") {
104+
if (typeof l !== "object") {
105105
return param._1;
106106
}
107107
_param = l;
@@ -111,26 +111,26 @@ function min_elt(_def, _param) {
111111
}
112112

113113
function remove_min_elt(l, v, r) {
114-
if (typeof l === "string") {
114+
if (typeof l !== "object") {
115115
return r;
116116
} else {
117117
return bal(remove_min_elt(l._0, l._1, l._2), v, r);
118118
}
119119
}
120120

121121
function internal_merge(l, r) {
122-
if (typeof l === "string") {
122+
if (typeof l !== "object") {
123123
return r;
124124
}
125-
if (typeof r === "string") {
125+
if (typeof r !== "object") {
126126
return l;
127127
}
128128
var rv = r._1;
129129
return bal(l, min_elt(rv, r), remove_min_elt(r._0, rv, r._2));
130130
}
131131

132132
function remove(x, tree) {
133-
if (typeof tree === "string") {
133+
if (typeof tree !== "object") {
134134
return "Empty";
135135
}
136136
var r = tree._2;
@@ -149,7 +149,7 @@ function remove(x, tree) {
149149
function mem(x, _param) {
150150
while(true) {
151151
var param = _param;
152-
if (typeof param === "string") {
152+
if (typeof param !== "object") {
153153
return false;
154154
}
155155
var c = compare_int(x, param._1);
@@ -180,7 +180,7 @@ for(var i$2 = 0; i$2 <= 100000; ++i$2){
180180

181181
var match = v;
182182

183-
if (typeof match !== "string") {
183+
if (typeof match === "object") {
184184
console.log("impossible");
185185
}
186186

jscomp/test/bdd.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var Caml_array = require("../../lib/js/caml_array.js");
55
function $$eval(_bdd, vars) {
66
while(true) {
77
var bdd = _bdd;
8-
if (typeof bdd === "string") {
8+
if (typeof bdd !== "object") {
99
if (bdd === "One") {
1010
return true;
1111
} else {
@@ -22,7 +22,7 @@ function $$eval(_bdd, vars) {
2222
}
2323

2424
function getId(bdd) {
25-
if (typeof bdd === "string") {
25+
if (typeof bdd !== "object") {
2626
if (bdd === "One") {
2727
return 1;
2828
} else {
@@ -64,7 +64,7 @@ function resize(newSize) {
6464
return ;
6565
}
6666
var n = bucket.hd;
67-
if (typeof n === "string") {
67+
if (typeof n !== "object") {
6868
if (n === "One") {
6969
throw {
7070
RE_EXN_ID: "Assert_failure",
@@ -140,7 +140,7 @@ function mkNode(low, v, high) {
140140
var b = _b;
141141
if (b) {
142142
var n = b.hd;
143-
if (typeof n === "string") {
143+
if (typeof n !== "object") {
144144
if (n === "One") {
145145
throw {
146146
RE_EXN_ID: "Assert_failure",
@@ -217,7 +217,7 @@ function hash(x, y) {
217217
}
218218

219219
function not(n) {
220-
if (typeof n === "string") {
220+
if (typeof n !== "object") {
221221
if (n === "One") {
222222
return "Zero";
223223
} else {
@@ -236,7 +236,7 @@ function not(n) {
236236
}
237237

238238
function and2(n1, n2) {
239-
if (typeof n1 === "string") {
239+
if (typeof n1 !== "object") {
240240
if (n1 === "One") {
241241
return n2;
242242
} else {
@@ -247,7 +247,7 @@ function and2(n1, n2) {
247247
var i1 = n1._2;
248248
var v1 = n1._1;
249249
var l1 = n1._0;
250-
if (typeof n2 === "string") {
250+
if (typeof n2 !== "object") {
251251
if (n2 === "One") {
252252
return n1;
253253
} else {
@@ -283,7 +283,7 @@ function and2(n1, n2) {
283283
}
284284

285285
function xor(n1, n2) {
286-
if (typeof n1 === "string") {
286+
if (typeof n1 !== "object") {
287287
if (n1 === "One") {
288288
return not(n2);
289289
} else {
@@ -294,7 +294,7 @@ function xor(n1, n2) {
294294
var i1 = n1._2;
295295
var v1 = n1._1;
296296
var l1 = n1._0;
297-
if (typeof n2 === "string") {
297+
if (typeof n2 !== "object") {
298298
if (n2 === "One") {
299299
return not(n1);
300300
} else {

jscomp/test/defunctor_make_test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var Comparable = {
1616
};
1717

1818
function height(param) {
19-
if (typeof param === "string") {
19+
if (typeof param !== "object") {
2020
return 0;
2121
} else {
2222
return param._4;
@@ -37,11 +37,11 @@ function create(l, x, d, r) {
3737

3838
function bal(l, x, d, r) {
3939
var hl;
40-
hl = typeof l === "string" ? 0 : l._4;
40+
hl = typeof l !== "object" ? 0 : l._4;
4141
var hr;
42-
hr = typeof r === "string" ? 0 : r._4;
42+
hr = typeof r !== "object" ? 0 : r._4;
4343
if (hl > (hr + 2 | 0)) {
44-
if (typeof l === "string") {
44+
if (typeof l !== "object") {
4545
throw {
4646
RE_EXN_ID: "Invalid_argument",
4747
_1: "Map.bal",
@@ -55,7 +55,7 @@ function bal(l, x, d, r) {
5555
if (height(ll) >= height(lr)) {
5656
return create(ll, lv, ld, create(lr, x, d, r));
5757
}
58-
if (typeof lr !== "string") {
58+
if (typeof lr === "object") {
5959
return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r));
6060
}
6161
throw {
@@ -73,7 +73,7 @@ function bal(l, x, d, r) {
7373
_4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0
7474
};
7575
}
76-
if (typeof r === "string") {
76+
if (typeof r !== "object") {
7777
throw {
7878
RE_EXN_ID: "Invalid_argument",
7979
_1: "Map.bal",
@@ -87,7 +87,7 @@ function bal(l, x, d, r) {
8787
if (height(rr) >= height(rl)) {
8888
return create(create(l, x, d, rl), rv, rd, rr);
8989
}
90-
if (typeof rl !== "string") {
90+
if (typeof rl === "object") {
9191
return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr));
9292
}
9393
throw {
@@ -98,7 +98,7 @@ function bal(l, x, d, r) {
9898
}
9999

100100
function add(x, data, compare, param) {
101-
if (typeof param === "string") {
101+
if (typeof param !== "object") {
102102
return /* Node */{
103103
_0: "Empty",
104104
_1: x,

jscomp/test/demo_int_map.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
function height(param) {
5-
if (typeof param === "string") {
5+
if (typeof param !== "object") {
66
return 0;
77
} else {
88
return param.h;
@@ -23,11 +23,11 @@ function create(l, x, d, r) {
2323

2424
function bal(l, x, d, r) {
2525
var hl;
26-
hl = typeof l === "string" ? 0 : l.h;
26+
hl = typeof l !== "object" ? 0 : l.h;
2727
var hr;
28-
hr = typeof r === "string" ? 0 : r.h;
28+
hr = typeof r !== "object" ? 0 : r.h;
2929
if (hl > (hr + 2 | 0)) {
30-
if (typeof l === "string") {
30+
if (typeof l !== "object") {
3131
throw {
3232
RE_EXN_ID: "Invalid_argument",
3333
_1: "Map.bal",
@@ -41,7 +41,7 @@ function bal(l, x, d, r) {
4141
if (height(ll) >= height(lr)) {
4242
return create(ll, lv, ld, create(lr, x, d, r));
4343
}
44-
if (typeof lr !== "string") {
44+
if (typeof lr === "object") {
4545
return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r));
4646
}
4747
throw {
@@ -59,7 +59,7 @@ function bal(l, x, d, r) {
5959
h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0
6060
};
6161
}
62-
if (typeof r === "string") {
62+
if (typeof r !== "object") {
6363
throw {
6464
RE_EXN_ID: "Invalid_argument",
6565
_1: "Map.bal",
@@ -73,7 +73,7 @@ function bal(l, x, d, r) {
7373
if (height(rr) >= height(rl)) {
7474
return create(create(l, x, d, rl), rv, rd, rr);
7575
}
76-
if (typeof rl !== "string") {
76+
if (typeof rl === "object") {
7777
return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr));
7878
}
7979
throw {
@@ -84,7 +84,7 @@ function bal(l, x, d, r) {
8484
}
8585

8686
function add(x, data, m) {
87-
if (typeof m === "string") {
87+
if (typeof m !== "object") {
8888
return /* Node */{
8989
l: "Empty",
9090
v: x,
@@ -130,7 +130,7 @@ function add(x, data, m) {
130130
function find(x, _param) {
131131
while(true) {
132132
var param = _param;
133-
if (typeof param === "string") {
133+
if (typeof param !== "object") {
134134
throw {
135135
RE_EXN_ID: "Not_found",
136136
Error: new Error()

jscomp/test/demo_page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function sum(n) {
2121
}
2222

2323
function map(f, param) {
24-
if (typeof param === "string") {
24+
if (typeof param !== "object") {
2525
return "Nil";
2626
} else {
2727
return /* Cons */{

0 commit comments

Comments
 (0)