feat(es/minifier): Drop more expressions from parallel optimizer (#3303)

swc_ecma_minifier:
 - `pure`: Implement more rule for dropping useless expressions.
This commit is contained in:
Donny/강동윤 2022-01-18 16:45:47 +09:00 committed by GitHub
parent cea7d21ca4
commit 210ecf83bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
94 changed files with 239 additions and 193 deletions

View File

@ -37,10 +37,10 @@ function _unsupportedIterableToArray(o, minLen) {
}
var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
try {
for(var ref, ref1, ref2, _step, _iterator = [
for(var ref, _step, _iterator = [
2,
"3"
][Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0)ref1 = (ref = _slicedToArray(_step.value, 2))[0], void 0 === ref1, ref2 = ref[1], void 0 === ref2;
][Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0)(ref = _slicedToArray(_step.value, 2))[0], ref[1];
} catch (err) {
_didIteratorError = !0, _iteratorError = err;
} finally{

View File

@ -1,6 +1,6 @@
var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
try {
for(var ref, ref1, ref2, _step, _iterator = [][Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0)ref1 = (ref = _step.value).a, void 0 === ref1, ref2 = ref.b, void 0 === ref2;
for(var ref, _step, _iterator = [][Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0)(ref = _step.value).a, ref.b;
} catch (err) {
_didIteratorError = !0, _iteratorError = err;
} finally{

View File

@ -1,2 +1,2 @@
var E, F, E, F;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", (F = F || (F = {}))[F.c = 0] = "c", F[F.d = 1] = "d", E.a + 0, E.a + E.b, E.a + E.b, E.a + F.c;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", (F = F || (F = {}))[F.c = 0] = "c", F[F.d = 1] = "d", E.a, E.a + E.b, E.a + E.b, E.a + F.c;

View File

@ -1,2 +1,2 @@
var E, F, E, F;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", (F = F || (F = {}))[F.c = 0] = "c", F[F.d = 1] = "d", E.a + 0, E.a + E.b, E.a + E.b, E.a + F.c;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", (F = F || (F = {}))[F.c = 0] = "c", F[F.d = 1] = "d", E.a, E.a + E.b, E.a + E.b, E.a + F.c;

View File

@ -1,2 +1,2 @@
var E, E;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c", (void 0) + E.a, (void 0) + E.a, E.a + void 0, E.a + void 0;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c", E.a, E.a, E.a, E.a;

View File

@ -1,2 +1,2 @@
var E, E;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c", (void 0) + E.a, (void 0) + E.a, E.a + void 0, E.a + void 0;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c", E.a, E.a, E.a, E.a;

View File

@ -1,4 +1,4 @@
var E1, E1;
(E1 = E1 || (E1 = {}))[E1.A = 0] = "A", E1[E1.B = 1] = "B", E1[E1.C = 2] = "C";
const foo = require("./foo_0");
0 === foo.E1.A;
foo.E1.A;

View File

@ -1,2 +1,2 @@
var E1, E1;
(E1 = E1 || (E1 = {}))[E1.A = 0] = "A", E1[E1.B = 1] = "B", E1[E1.C = 2] = "C", 0 === require("./foo_0").E1.A;
(E1 = E1 || (E1 = {}))[E1.A = 0] = "A", E1[E1.B = 1] = "B", E1[E1.C = 2] = "C", require("./foo_0").E1.A;

View File

@ -1,2 +1,2 @@
var E, E;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", (void 0) * E.a, (void 0) * E.b, (void 0) / E.a, E.b / void 0, (void 0) % E.a, E.b % void 0, (void 0) - E.a, E.b - void 0, (void 0) << E.a, 0 << void 0, E.b << void 0, (void 0) >> E.a, 0 >> void 0, E.b >> void 0, (void 0) >>> E.a, 0 >>> void 0, E.b >>> void 0, (void 0) & E.a, (void 0) & E.b, (void 0) ^ E.a, (void 0) ^ E.b, (void 0) | E.a, (void 0) | E.b;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E.a, E.b, E.a, E.b, E.a, E.b, E.a, E.b, E.a, E.b, E.a, E.b, E.a, E.b, E.a, E.b, E.a, E.b, E.a, E.b;

View File

@ -1,2 +1,2 @@
var E, E;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", (void 0) * E.a, (void 0) * E.b, (void 0) / E.a, E.b / void 0, (void 0) % E.a, E.b % void 0, (void 0) - E.a, E.b - void 0, (void 0) << E.a, 0 << void 0, E.b << void 0, (void 0) >> E.a, 0 >> void 0, E.b >> void 0, (void 0) >>> E.a, 0 >>> void 0, E.b >>> void 0, (void 0) & E.a, (void 0) & E.b, (void 0) ^ E.a, (void 0) ^ E.b, (void 0) | E.a, (void 0) | E.b;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E.a, E.b, E.a, E.b, E.a, E.b, E.a, E.b, E.a, E.b, E.a, E.b, E.a, E.b, E.a, E.b, E.a, E.b, E.a, E.b;

View File

@ -10,7 +10,7 @@ Wagon.circle = function(wagons) {
var db = new class extends Wagon {
load(files, format) {
if ("xmlolololol" === format) throw new Error("please do not use XML. It was a joke.");
super.speed(), 0 > super.weight();
super.speed(), super.weight();
}
constructor(){
super(), this.foonly = 12;

View File

@ -89,7 +89,7 @@ var Sql = function(Wagon1) {
key: "load",
value: function(files, format) {
if ("xmlolololol" === format) throw new Error("please do not use XML. It was a joke.");
_get(_getPrototypeOf(Sql.prototype), "speed", this).call(this), 0 > _get(_getPrototypeOf(Sql.prototype), "weight", this).call(this);
_get(_getPrototypeOf(Sql.prototype), "speed", this).call(this), _get(_getPrototypeOf(Sql.prototype), "weight", this).call(this);
}
}
]), Sql;

View File

@ -1,2 +1,2 @@
var BOOLEAN, NUMBER;
new Date(), NUMBER.toString(), new Object, new Date(), void 0 == BOOLEAN, NUMBER.toString(), new Object;
var NUMBER;
new Date(), NUMBER.toString(), new Object, new Date(), NUMBER.toString(), new Object;

View File

@ -1,2 +1,2 @@
var BOOLEAN, NUMBER;
new Date(), NUMBER.toString(), new Object, new Date(), void 0 == BOOLEAN, NUMBER.toString(), new Object;
var NUMBER;
new Date(), NUMBER.toString(), new Object, new Date(), NUMBER.toString(), new Object;

View File

@ -1,2 +1,2 @@
var E, E, a, b, c, d, e;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c", a < b, a < c, a < d, a < e, b < a, b < c, b < d, b < e, c < a, c < b, c < d, c < e, d < a, d < b, d < c, d < e, e < a, e < b, e < c, e < d, a > b, a > c, a > d, a > e, b > a, b > c, b > d, b > e, c > a, c > b, c > d, c > e, d > a, d > b, d > c, d > e, e > a, e > b, e > c, e > d, a <= b, a <= c, a <= d, a <= e, b <= a, b <= c, b <= d, b <= e, c <= a, c <= b, c <= d, c <= e, d <= a, d <= b, d <= c, d <= e, e <= a, e <= b, e <= c, e <= d, a >= b, a >= c, a >= d, a >= e, b >= a, b >= c, b >= d, b >= e, c >= a, c >= b, c >= d, c >= e, d >= a, d >= b, d >= c, d >= e, e >= a, e >= b, e >= c, e >= d, a == b, a == c, a == d, a == e, b == a, b == c, b == d, b == e, c == a, c == b, c == d, c == e, d == a, d == b, d == c, d == e, e == a, e == b, e == c, e == d, a != b, a != c, a != d, a != e, b != a, b != c, b != d, b != e, c != a, c != b, c != d, c != e, d != a, d != b, d != c, d != e, e != a, e != b, e != c, e != d, a === b, a === c, a === d, a === e, b === a, b === c, b === d, b === e, c === a, c === b, c === d, c === e, d === a, d === b, d === c, d === e, e === a, e === b, e === c, e === d, a !== b, a !== c, a !== d, a !== e, b !== a, b !== c, b !== d, b !== e, c !== a, c !== b, c !== d, c !== e, d !== a, d !== b, d !== c, d !== e, e !== a, e !== b, e !== c, e !== d;
var E, E;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c";

View File

@ -1,2 +1,2 @@
var E, E, a, b, c, d, e;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c", a < b, a < c, a < d, a < e, b < a, b < c, b < d, b < e, c < a, c < b, c < d, c < e, d < a, d < b, d < c, d < e, e < a, e < b, e < c, e < d, a > b, a > c, a > d, a > e, b > a, b > c, b > d, b > e, c > a, c > b, c > d, c > e, d > a, d > b, d > c, d > e, e > a, e > b, e > c, e > d, a <= b, a <= c, a <= d, a <= e, b <= a, b <= c, b <= d, b <= e, c <= a, c <= b, c <= d, c <= e, d <= a, d <= b, d <= c, d <= e, e <= a, e <= b, e <= c, e <= d, a >= b, a >= c, a >= d, a >= e, b >= a, b >= c, b >= d, b >= e, c >= a, c >= b, c >= d, c >= e, d >= a, d >= b, d >= c, d >= e, e >= a, e >= b, e >= c, e >= d, a == b, a == c, a == d, a == e, b == a, b == c, b == d, b == e, c == a, c == b, c == d, c == e, d == a, d == b, d == c, d == e, e == a, e == b, e == c, e == d, a != b, a != c, a != d, a != e, b != a, b != c, b != d, b != e, c != a, c != b, c != d, c != e, d != a, d != b, d != c, d != e, e != a, e != b, e != c, e != d, a === b, a === c, a === d, a === e, b === a, b === c, b === d, b === e, c === a, c === b, c === d, c === e, d === a, d === b, d === c, d === e, e === a, e === b, e === c, e === d, a !== b, a !== c, a !== d, a !== e, b !== a, b !== c, b !== d, b !== e, c !== a, c !== b, c !== d, c !== e, d !== a, d !== b, d !== c, d !== e, e !== a, e !== b, e !== c, e !== d;
var E, E;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c";

View File

@ -1,2 +1,2 @@
var E, E, a, b;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c", a < b, b < a, E.a < b, b < E.a, E.a < 0, 0 < E.a, a > b, b > a, E.a > b, b > E.a, E.a > 0, 0 > E.a, a <= b, b <= a, E.a <= b, b <= E.a, E.a <= 0, 0 <= E.a, a >= b, b >= a, E.a >= b, b >= E.a, E.a >= 0, 0 >= E.a, a == b, b == a, E.a == b, b == E.a, 0 == E.a, 0 == E.a, a != b, b != a, E.a != b, b != E.a, 0 != E.a, 0 != E.a, a === b, b === a, E.a === b, b === E.a, 0 === E.a, 0 === E.a, a !== b, b !== a, E.a !== b, b !== E.a, 0 !== E.a, 0 !== E.a;
var E, E;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c", E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a;

View File

@ -1,2 +1,2 @@
var E, E, a, b;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c", a < b, b < a, E.a < b, b < E.a, E.a < 0, 0 < E.a, a > b, b > a, E.a > b, b > E.a, E.a > 0, 0 > E.a, a <= b, b <= a, E.a <= b, b <= E.a, E.a <= 0, 0 <= E.a, a >= b, b >= a, E.a >= b, b >= E.a, E.a >= 0, 0 >= E.a, a == b, b == a, E.a == b, b == E.a, 0 == E.a, 0 == E.a, a != b, b != a, E.a != b, b != E.a, 0 != E.a, 0 != E.a, a === b, b === a, E.a === b, b === E.a, 0 === E.a, 0 === E.a, a !== b, b !== a, E.a !== b, b !== E.a, 0 !== E.a, 0 !== E.a;
var E, E;
(E = E || (E = {}))[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c", E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a, E.a;

View File

@ -41,8 +41,8 @@ function _unsupportedIterableToArray(o, minLen) {
}
}
var _undefined = _slicedToArray(void 0, 2);
_undefined[0], _undefined[1], void 0 !== tmp, void 0 === tmp1;
var _undefined1 = _slicedToArray(void 0, 2), tmp = _undefined1[0], tmp1 = _undefined1[1];
_undefined[0], _undefined[1];
var _undefined1 = _slicedToArray(void 0, 2);
function foo() {
return [
1,
@ -50,6 +50,7 @@ function foo() {
3
];
}
_undefined1[0], _undefined1[1];
var ref = _slicedToArray(foo(), 2);
ref[0], ref[1], (_arrayWithHoles(arr = foo()) || _iterableToArray(arr) || _unsupportedIterableToArray(arr, i) || _nonIterableRest()).slice(0);
var arr, arr, ref1 = _slicedToArray(function(arr) {

View File

@ -41,8 +41,8 @@ function _unsupportedIterableToArray(o, minLen) {
}
}
var _undefined = _slicedToArray(void 0, 2);
_undefined[0], _undefined[1], void 0 !== tmp, void 0 === tmp1;
var _undefined1 = _slicedToArray(void 0, 2), tmp = _undefined1[0], tmp1 = _undefined1[1];
_undefined[0], _undefined[1];
var _undefined1 = _slicedToArray(void 0, 2);
function foo() {
return [
1,
@ -50,6 +50,7 @@ function foo() {
3
];
}
_undefined1[0], _undefined1[1];
var ref = _slicedToArray(foo(), 2);
ref[0], ref[1], (_arrayWithHoles(arr = foo()) || _iterableToArray(arr) || _unsupportedIterableToArray(arr, i) || _nonIterableRest()).slice(0);
var arr, arr, ref1 = _slicedToArray(function(arr) {

View File

@ -41,8 +41,8 @@ function _unsupportedIterableToArray(o, minLen) {
}
}
var _undefined = _slicedToArray(void 0, 2);
_undefined[0], _undefined[1], void 0 !== tmp, void 0 === tmp1;
var _undefined1 = _slicedToArray(void 0, 2), tmp = _undefined1[0], tmp1 = _undefined1[1];
_undefined[0], _undefined[1];
var _undefined1 = _slicedToArray(void 0, 2);
function foo() {
return [
1,
@ -50,6 +50,7 @@ function foo() {
3
];
}
_undefined1[0], _undefined1[1];
var ref = _slicedToArray(foo(), 2);
ref[0], ref[1], (_arrayWithHoles(arr = foo()) || _iterableToArray(arr) || _unsupportedIterableToArray(arr, i) || _nonIterableRest()).slice(0);
var arr, arr, ref1 = _slicedToArray(function(arr) {

View File

@ -37,9 +37,7 @@ function _unsupportedIterableToArray(o, minLen) {
}
var ref = [
1
];
ref[0], ref[1];
var ref1 = [
], a = ref[0], tmp = ref[1], ref1 = [
1
];
ref1[0], ref1[1], ref1[2];

View File

@ -47,7 +47,7 @@ var _ref = {}, key = order(0), key1 = order(2), tmp2 = _ref[key];
return ("string" === hint ? String : Number)(input);
}(arg, "string");
return "symbol" === _typeof(key2) ? key2 : String(key2);
})), void 0 === tmp3;
}));
var _ref1 = [
{
x: 1
@ -82,5 +82,5 @@ var _ref1 = [
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}()), ref = __ref[0], ref = null !== ref ? ref : function(e) {
throw e;
}(new TypeError("Cannot destructure undefined")), tmp3 = __ref[1];
_extends({}, _ref1[0]);
}(new TypeError("Cannot destructure undefined"));
__ref[1], _extends({}, _ref1[0]);

View File

@ -1,4 +1,4 @@
var _c, d;
var _c;
(function(source, excluded) {
if (null == source) return {};
var key, i, target = function(source, excluded) {
@ -18,4 +18,4 @@ var _c, d;
}
}).x, [
"a"
]), (void 0 === (d = _c.x), d).a;
]), _c.x.a;

View File

@ -2,18 +2,16 @@
var tmp = {
b21: "world"
};
(void 0 === tmp ? {
b21: "string"
} : tmp).b21, ({
1: "string"
})[1], void 0 === _b4;
var _b4 = 100000;
function foo1() {
return {
prop1: 2
};
}
({
(void 0 === tmp ? {
b21: "string"
} : tmp).b21, ({
1: "string"
})[1], ({
1: !0
})[1], ({
2: !0

View File

@ -2,18 +2,16 @@
var tmp = {
b21: "world"
};
(void 0 === tmp ? {
b21: "string"
} : tmp).b21, ({
1: "string"
})[1], void 0 === _b4;
var _b4 = 100000;
function foo1() {
return {
prop1: 2
};
}
({
(void 0 === tmp ? {
b21: "string"
} : tmp).b21, ({
1: "string"
})[1], ({
1: !0
})[1], ({
2: !0

View File

@ -60,7 +60,7 @@ var arr, ref = [
}(arr) || _unsupportedIterableToArray(arr) || function() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}()), 2);
ref1[0], ref1[1], void 0 === tmp4;
ref1[0], ref1[1];
var _e = _slicedToArray([
1,
2,
@ -76,8 +76,4 @@ var _e = _slicedToArray([
f5: 0
}
], 3), f1 = _f[0], f2 = _f[1], ref2 = _f[2];
ref2.f3, ref2.f5, void 0 === _g1;
var _g1 = [
1,
2
];
ref2.f3, ref2.f5;

View File

@ -60,7 +60,7 @@ var arr, ref = [
}(arr) || _unsupportedIterableToArray(arr) || function() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}()), 2);
ref1[0], ref1[1], void 0 === tmp4;
ref1[0], ref1[1];
var _e = _slicedToArray([
1,
2,
@ -76,8 +76,4 @@ var _e = _slicedToArray([
f5: 0
}
], 3), f1 = _f[0], f2 = _f[1], ref2 = _f[2];
ref2.f3, ref2.f5, void 0 === _g1;
var _g1 = [
1,
2
];
ref2.f3, ref2.f5;

View File

@ -60,7 +60,7 @@ var arr, ref = [
}(arr) || _unsupportedIterableToArray(arr) || function() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}()), 2);
ref1[0], ref1[1], void 0 === tmp4;
ref1[0], ref1[1];
var _e = _slicedToArray([
1,
2,
@ -76,8 +76,4 @@ var _e = _slicedToArray([
f5: 0
}
], 3), f1 = _f[0], f2 = _f[1], ref2 = _f[2];
ref2.f3, ref2.f5, void 0 === _g1;
var _g1 = [
1,
2
];
ref2.f3, ref2.f5;

View File

@ -11,8 +11,4 @@ var ref1 = [
c5: 0
}
], c1 = ref1[0], c2 = ref1[1], ref2 = ref1[2];
ref2.c3, ref2.c5, ref1.slice(4), void 0 === _d1;
var _d1 = [
1,
2
]; // Error
ref2.c3, ref2.c5, ref1.slice(4);

View File

@ -37,8 +37,7 @@ function _unsupportedIterableToArray(o, minLen) {
}
}
function f2(param1) {
void 0 === _y, param1.x;
var _y = param1.y;
param1.x, param1.y;
}
function f3(param2) {
param2.x, param2.y;

View File

@ -1,5 +1,5 @@
var Foo;
(Foo || (Foo = {})).answer = 42, module.exports = Foo;
const foo = require("./foo_0");
42 === foo.answer;
foo.answer;
export { };

View File

@ -1,3 +1,3 @@
var Foo;
(Foo || (Foo = {})).answer = 42, module.exports = Foo, 42 === require("./foo_0").answer;
(Foo || (Foo = {})).answer = 42, module.exports = Foo, require("./foo_0").answer;
export { };

View File

@ -1,4 +1,4 @@
let a;
for(let x in a)a[x + 1], a[x - 1], 1 === x, x.unknownProperty;
for(let x in a)a[x + 1], a[x - 1], x.unknownProperty;
for(var i in a);
for(var j in a);

View File

@ -1,6 +1,6 @@
for(var x in a){
var a;
a[x + 1], a[x - 1], 1 === x, x.unknownProperty;
a[x + 1], a[x - 1], x.unknownProperty;
}
for(var i in a);
for(var j in a);

View File

@ -42,7 +42,7 @@ var map = new Map([
]
]), _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
try {
for(var ref, ref1, ref2, _step, _iterator = map[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0)ref1 = (ref = _slicedToArray(_step.value, 2))[0], void 0 === ref1, ref2 = ref[1], void 0 !== ref2;
for(var ref, _step, _iterator = map[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0)(ref = _slicedToArray(_step.value, 2))[0], ref[1];
} catch (err) {
_didIteratorError = !0, _iteratorError = err;
} finally{

View File

@ -42,7 +42,7 @@ var map = new Map([
]
]), _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
try {
for(var ref, ref1, ref2, _step, _iterator = map[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0)ref1 = (ref = _slicedToArray(_step.value, 2))[0], void 0 !== ref1, ref2 = ref[1], void 0 === ref2;
for(var ref, _step, _iterator = map[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0)(ref = _slicedToArray(_step.value, 2))[0], ref[1];
} catch (err) {
_didIteratorError = !0, _iteratorError = err;
} finally{

View File

@ -1,5 +1,5 @@
var foo;
(foo || (foo = {})).answer = 42;
const foo = require("./foo_0");
42 === foo.answer;
foo.answer;
export { };

View File

@ -1,5 +1,5 @@
var foo;
(foo || (foo = {})).answer = 42;
var foo = require("./foo_0");
42 === foo.answer;
foo.answer;
export { };

View File

@ -1,3 +1,3 @@
var a, b;
a instanceof class {
} && (a.narrowed, a = 123), "number" == typeof a && a.toFixed(), "object" == typeof b, b.toString();
} && (a.narrowed, a = 123), "number" == typeof a && a.toFixed(), b.toString();

View File

@ -4,4 +4,4 @@ var a, b, left, right, Narrow = function() {
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
}(this, Narrow);
};
left = a, (null != (right = Narrow) && "undefined" != typeof Symbol && right[Symbol.hasInstance] ? right[Symbol.hasInstance](left) : left instanceof right) && (a.narrowed, a = 123), "number" == typeof a && a.toFixed(), "object" == typeof b, b.toString();
left = a, (null != (right = Narrow) && "undefined" != typeof Symbol && right[Symbol.hasInstance] ? right[Symbol.hasInstance](left) : left instanceof right) && (a.narrowed, a = 123), "number" == typeof a && a.toFixed(), b.toString();

View File

@ -1,2 +1,2 @@
var a;
a.toString, a = void 0, a = null, a = b, a = c, a = a = d, "object" != typeof b && b.toString(), "object" == typeof b && (a = b), "object" == typeof d && (b = d), d.toString(), null == d, d.toString(), null === d, d.toString(), "undefined" == typeof d, d.toString();
a.toString, a = void 0, a = null, a = b, a = c, a = a = d, "object" != typeof b && b.toString(), "object" == typeof b && (a = b), "object" == typeof d && (b = d), d.toString(), d.toString(), d.toString(), d.toString();

View File

@ -1,2 +1,2 @@
var a;
a.toString, a = void 0, a = null, a = b, a = c, a = a = d, "object" != typeof b && b.toString(), "object" == typeof b && (a = b), "object" == typeof d && (b = d), d.toString(), null == d, d.toString(), null === d, d.toString(), "undefined" == typeof d, d.toString();
a.toString, a = void 0, a = null, a = b, a = c, a = a = d, "object" != typeof b && b.toString(), "object" == typeof b && (a = b), "object" == typeof d && (b = d), d.toString(), d.toString(), d.toString(), d.toString();

View File

@ -1,2 +1,2 @@
const maybeBool = !1;
null == maybeBool || maybeBool || foo(), null == maybeBool, foo(), foo();
null == maybeBool || maybeBool || foo(), foo(), foo();

View File

@ -1,2 +1,2 @@
var maybeBool = !1;
null == maybeBool || maybeBool || foo(), null == maybeBool, foo(), foo();
null == maybeBool || maybeBool || foo(), foo(), foo();

View File

@ -1,2 +1,2 @@
let map1 = {}, guid = "21EC2020-3AEA-4069-A2DD-08002B30309D";
map1[guid] = 123, ({})[12345] = "hello", guid.toLowerCase(), 12345..toPrecision(0), "" === guid, guid == guid;
map1[guid] = 123, ({})[12345] = "hello", guid.toLowerCase(), 12345..toPrecision(0);

View File

@ -1,2 +1,2 @@
var map1 = {}, guid = "21EC2020-3AEA-4069-A2DD-08002B30309D";
map1[guid] = 123, ({})[12345] = "hello", guid.toLowerCase(), 12345..toPrecision(0), "" === guid, guid == guid;
map1[guid] = 123, ({})[12345] = "hello", guid.toLowerCase(), 12345..toPrecision(0);

View File

@ -40,4 +40,4 @@ function _unsupportedIterableToArray(o, minLen) {
}
return _arr;
}
})(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest()))[0], void 0 === ref[1];
})(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest()))[0], ref[1];

View File

@ -4,7 +4,7 @@ function _arrayLikeToArray(arr, len) {
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
return arr2;
}
void 0 === (ref = ((function(arr) {
(ref = ((function(arr) {
if (Array.isArray(arr)) return arr;
})(arr = [
"",

View File

@ -1,2 +1,2 @@
let abc = "ABC", xyz = "XYZ", abcOrXyzOrNumber = abc || xyz || 100;
abcOrXyzOrNumber++, --abcOrXyzOrNumber, abc < xyz, abc === xyz, abc != xyz;
abcOrXyzOrNumber++, --abcOrXyzOrNumber;

View File

@ -1,2 +1,2 @@
var abc = "ABC", xyz = "XYZ", abcOrXyzOrNumber = abc || xyz || 100;
abcOrXyzOrNumber++, --abcOrXyzOrNumber, abc < xyz, abc === xyz, abc != xyz;
abcOrXyzOrNumber++, --abcOrXyzOrNumber;

View File

@ -1,2 +1,2 @@
var x, obj;
(void 0 === x ? "undefined" : (obj = x) && "undefined" != typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj) == "symbol";
void 0 === x || (obj = x) && "undefined" != typeof Symbol && obj.constructor === Symbol;

View File

@ -1,2 +1,2 @@
if ("string" != typeof strOrNum, ("string" == typeof strOrNumOrBool || "number" == typeof strOrNumOrBool) && (strOrNum = strOrNumOrBool), "string" != typeof strOrNumOrBool && "number" != typeof strOrNumOrBool || (strOrNum = strOrNumOrBool), "string" != typeof strOrNumOrBool && "number" != typeof strOrNumOrBool || (strOrNum = strOrNumOrBool), "string" != typeof strOrNumOrBool && "number" != typeof strOrNumOrBool || (strOrNum = strOrNumOrBool), "string" != typeof strOrNumOrBool && numOrBool !== strOrNumOrBool) numOrBool = strOrNumOrBool;
else var strOrNum, strOrNumOrBool, numOrBool;
if ("string" == typeof strOrNumOrBool || "number" == typeof strOrNumOrBool, "string" != typeof strOrNumOrBool && "number" != typeof strOrNumOrBool, "string" != typeof strOrNumOrBool && "number" != typeof strOrNumOrBool, "string" != typeof strOrNumOrBool && "number" != typeof strOrNumOrBool, "string" != typeof strOrNumOrBool && numOrBool !== strOrNumOrBool) numOrBool = strOrNumOrBool;
else var strOrNumOrBool, numOrBool;

View File

@ -1,2 +1,2 @@
if ("string" != typeof strOrNum, ("string" == typeof strOrNumOrBool || "number" == typeof strOrNumOrBool) && (strOrNum = strOrNumOrBool), "string" != typeof strOrNumOrBool && "number" != typeof strOrNumOrBool || (strOrNum = strOrNumOrBool), "string" != typeof strOrNumOrBool && "number" != typeof strOrNumOrBool || (strOrNum = strOrNumOrBool), "string" != typeof strOrNumOrBool && "number" != typeof strOrNumOrBool || (strOrNum = strOrNumOrBool), "string" != typeof strOrNumOrBool && numOrBool !== strOrNumOrBool) numOrBool = strOrNumOrBool;
else var strOrNum, strOrNumOrBool, numOrBool;
if ("string" == typeof strOrNumOrBool || "number" == typeof strOrNumOrBool, "string" != typeof strOrNumOrBool && "number" != typeof strOrNumOrBool, "string" != typeof strOrNumOrBool && "number" != typeof strOrNumOrBool, "string" != typeof strOrNumOrBool && "number" != typeof strOrNumOrBool, "string" != typeof strOrNumOrBool && numOrBool !== strOrNumOrBool) numOrBool = strOrNumOrBool;
else var strOrNumOrBool, numOrBool;

View File

@ -1,2 +0,0 @@
var strOrNum, strOrBool, numOrBool, strOrNumOrBool, boolOrC;
"boolean" == typeof strOrBool, "boolean" == typeof numOrBool, "boolean" == typeof strOrNumOrBool || (strOrNum = strOrNumOrBool), "boolean" == typeof boolOrC, "boolean" == typeof strOrNum, "boolean" != typeof strOrBool, "boolean" != typeof numOrBool, "boolean" != typeof strOrNumOrBool && (strOrNum = strOrNumOrBool), "boolean" != typeof boolOrC, "boolean" != typeof strOrNum;

View File

@ -1,7 +1,6 @@
var strOrNum, strOrBool, numOrBool, strOrNumOrBool, boolOrC, C = function() {
var C = function() {
"use strict";
!function(instance, Constructor) {
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
}(this, C);
};
"boolean" == typeof strOrBool, "boolean" == typeof numOrBool, "boolean" == typeof strOrNumOrBool || (strOrNum = strOrNumOrBool), "boolean" == typeof boolOrC, "boolean" == typeof strOrNum, "boolean" != typeof strOrBool, "boolean" != typeof numOrBool, "boolean" != typeof strOrNumOrBool && (strOrNum = strOrNumOrBool), "boolean" != typeof boolOrC, "boolean" != typeof strOrNum;

View File

@ -1,7 +1,7 @@
var obj, strOrNum, strOrBool, numOrBool, strOrC, C = function() {
var obj, strOrC, C = function() {
"use strict";
!function(instance, Constructor) {
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
}(this, C);
};
"string" == typeof strOrNum, "boolean" == typeof strOrBool, "number" == typeof numOrBool, (void 0 === strOrC ? "undefined" : (obj = strOrC) && "undefined" != typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj) == "Object";
void 0 === strOrC || (obj = strOrC) && "undefined" != typeof Symbol && obj.constructor === Symbol;

View File

@ -1,7 +1,7 @@
var obj, strOrNum, strOrBool, numOrBool, strOrC, C = function() {
var obj, strOrC, C = function() {
"use strict";
!function(instance, Constructor) {
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
}(this, C);
};
"string" != typeof strOrNum, "boolean" != typeof strOrBool, "number" != typeof numOrBool, (void 0 === strOrC ? "undefined" : (obj = strOrC) && "undefined" != typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj) != "Object";
void 0 === strOrC || (obj = strOrC) && "undefined" != typeof Symbol && obj.constructor === Symbol;

View File

@ -1,3 +1,2 @@
if ("number" == typeof strOrNum, "number" == typeof numOrBool) ;
else var strOrNum, strOrBool, numOrBool, strOrNumOrBool, numOrC;
"number" == typeof strOrNumOrBool || (strOrBool = strOrNumOrBool), "number" == typeof numOrC, "number" == typeof strOrBool, "number" != typeof strOrNum, "number" != typeof numOrBool, "number" != typeof strOrNumOrBool && (strOrBool = strOrNumOrBool), "number" != typeof numOrC, "number" != typeof strOrBool;
if ("number" == typeof numOrBool) ;
else var numOrBool;

View File

@ -1,7 +1,6 @@
var strOrNum, strOrBool, numOrBool, strOrNumOrBool, numOrC, C = function() {
var C = function() {
"use strict";
!function(instance, Constructor) {
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
}(this, C);
};
"number" == typeof strOrNum, "number" == typeof numOrBool, "number" == typeof strOrNumOrBool || (strOrBool = strOrNumOrBool), "number" == typeof numOrC, "number" == typeof strOrBool, "number" != typeof strOrNum, "number" != typeof numOrBool, "number" != typeof strOrNumOrBool && (strOrBool = strOrNumOrBool), "number" != typeof numOrC, "number" != typeof strOrBool;

View File

@ -6,4 +6,4 @@ var strOrNumOrBool, strOrC, numOrC, boolOrC, _typeof = function(obj) {
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
}(this, C);
};
(void 0 === strOrC ? "undefined" : _typeof(strOrC)) === "Object", (void 0 === numOrC ? "undefined" : _typeof(numOrC)) === "Object", (void 0 === boolOrC ? "undefined" : _typeof(boolOrC)) === "Object", (void 0 === strOrC ? "undefined" : _typeof(strOrC)) === "Object", (void 0 === strOrNumOrBool ? "undefined" : _typeof(strOrNumOrBool)) === "Object", (void 0 === strOrC ? "undefined" : _typeof(strOrC)) !== "Object", (void 0 === numOrC ? "undefined" : _typeof(numOrC)) !== "Object", (void 0 === boolOrC ? "undefined" : _typeof(boolOrC)) !== "Object", (void 0 === strOrNumOrBool ? "undefined" : _typeof(strOrNumOrBool)) !== "Object";
void 0 === strOrC || _typeof(strOrC), void 0 === numOrC || _typeof(numOrC), void 0 === boolOrC || _typeof(boolOrC), void 0 === strOrC || _typeof(strOrC), void 0 === strOrNumOrBool || _typeof(strOrNumOrBool), void 0 === strOrC || _typeof(strOrC), void 0 === numOrC || _typeof(numOrC), void 0 === boolOrC || _typeof(boolOrC), void 0 === strOrNumOrBool || _typeof(strOrNumOrBool);

View File

@ -1,2 +0,0 @@
var strOrNum, strOrBool, numOrBool, strOrNumOrBool, strOrC;
"string" == typeof strOrNum, "string" == typeof strOrBool, "string" == typeof strOrNumOrBool || (numOrBool = strOrNumOrBool), "string" == typeof strOrC, "string" == typeof numOrBool, "string" != typeof strOrNum, "string" != typeof strOrBool, "string" != typeof strOrNumOrBool && (numOrBool = strOrNumOrBool), "string" != typeof strOrC, "string" != typeof numOrBool;

View File

@ -1,7 +1,6 @@
var strOrNum, strOrBool, numOrBool, strOrNumOrBool, strOrC, C = function() {
var C = function() {
"use strict";
!function(instance, Constructor) {
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
}(this, C);
};
"string" == typeof strOrNum, "string" == typeof strOrBool, "string" == typeof strOrNumOrBool || (numOrBool = strOrNumOrBool), "string" == typeof strOrC, "string" == typeof numOrBool, "string" != typeof strOrNum, "string" != typeof strOrBool, "string" != typeof strOrNumOrBool && (numOrBool = strOrNumOrBool), "string" != typeof strOrC, "string" != typeof numOrBool;

View File

@ -1,2 +1,2 @@
var var1, var2;
"string" == typeof var1 && var1.length, "string" == typeof var2;
var var1;
"string" == typeof var1 && var1.length;

View File

@ -1,2 +1,2 @@
var var1, var2;
"string" == typeof var1 && var1.length, "string" == typeof var2;
var var1;
"string" == typeof var1 && var1.length;

View File

@ -2,9 +2,9 @@ var m, m1;
!function(m) {
var x;
let m2;
m2 || (m2 = {}), "string" == typeof x || ("boolean" == typeof x, x.toString());
m2 || (m2 = {}), "string" == typeof x || x.toString();
}(m || (m = {})), (function(m1) {
var x, m2;
let m21;
(m2 = m21 || (m21 = {})).m3 || (m2.m3 = {}), "string" == typeof x || ("boolean" == typeof x, x.toString());
(m2 = m21 || (m21 = {})).m3 || (m2.m3 = {}), "string" == typeof x || x.toString();
})(m1 || (m1 = {}));

View File

@ -1,8 +1,8 @@
var m, m1;
!function(m) {
var x, m2;
m2 || (m2 = {}), "string" == typeof x || ("boolean" == typeof x, x.toString());
m2 || (m2 = {}), "string" == typeof x || x.toString();
}(m || (m = {})), (function(m1) {
var x, m2, m21;
(m21 = m2 || (m2 = {})).m3 || (m21.m3 = {}), "string" == typeof x || ("boolean" == typeof x, x.toString());
(m21 = m2 || (m2 = {})).m3 || (m21.m3 = {}), "string" == typeof x || x.toString();
})(m1 || (m1 = {}));

View File

@ -1,12 +1,12 @@
var num, strOrNum, var1, m1, m2, m3;
!function(m11) {
var var2, var3;
num = "string" == typeof var1 && var1.length, num = "string" == typeof var2 ? var2.length : var2, "string" == typeof var3, strOrNum = var3, m11.var3 = var3;
num = "string" == typeof var1 && var1.length, num = "string" == typeof var2 ? var2.length : var2, strOrNum = var3, m11.var3 = var3;
}(m1 || (m1 = {})), (function(m21) {
var var2, var3, m32, var4, var5;
let m31;
m32 = m31 || (m31 = {}), num = "string" == typeof var1 && var1.length, num = "string" == typeof var2 && var2.length, strOrNum = "string" == typeof var3 && var3, num = "string" == typeof var4 ? var4.length : var4, "string" == typeof var5, strOrNum = var5, m32.var5 = var5, m21.var3 = var3;
m32 = m31 || (m31 = {}), num = "string" == typeof var1 && var1.length, num = "string" == typeof var2 && var2.length, strOrNum = "string" == typeof var3 && var3, num = "string" == typeof var4 ? var4.length : var4, strOrNum = var5, m32.var5 = var5, m21.var3 = var3;
})(m2 || (m2 = {})), (function(m33) {
var m4, var2, var3;
m4 = m33.m4 || (m33.m4 = {}), num = "string" == typeof var1 && var1.length, num = "string" == typeof var2 ? var2.length : var2, "string" == typeof var3, strOrNum = var3, m4.var3 = var3;
m4 = m33.m4 || (m33.m4 = {}), num = "string" == typeof var1 && var1.length, num = "string" == typeof var2 ? var2.length : var2, strOrNum = var3, m4.var3 = var3;
})(m3 || (m3 = {}));

View File

@ -1,11 +1,11 @@
var num, strOrNum, var1, m1, m2, m3;
!function(m11) {
var var2, var3;
num = "string" == typeof var1 && var1.length, num = "string" == typeof var2 ? var2.length : var2, "string" == typeof var3, strOrNum = var3, m11.var3 = var3;
num = "string" == typeof var1 && var1.length, num = "string" == typeof var2 ? var2.length : var2, strOrNum = var3, m11.var3 = var3;
}(m1 || (m1 = {})), (function(m21) {
var var2, var3, m32, m31, var4, var5;
m31 = m32 || (m32 = {}), num = "string" == typeof var1 && var1.length, num = "string" == typeof var2 && var2.length, strOrNum = "string" == typeof var3 && var3, num = "string" == typeof var4 ? var4.length : var4, "string" == typeof var5, strOrNum = var5, m31.var5 = var5, m21.var3 = var3;
m31 = m32 || (m32 = {}), num = "string" == typeof var1 && var1.length, num = "string" == typeof var2 && var2.length, strOrNum = "string" == typeof var3 && var3, num = "string" == typeof var4 ? var4.length : var4, strOrNum = var5, m31.var5 = var5, m21.var3 = var3;
})(m2 || (m2 = {})), (function(m33) {
var m4, var2, var3;
m4 = m33.m4 || (m33.m4 = {}), num = "string" == typeof var1 && var1.length, num = "string" == typeof var2 ? var2.length : var2, "string" == typeof var3, strOrNum = var3, m4.var3 = var3;
m4 = m33.m4 || (m33.m4 = {}), num = "string" == typeof var1 && var1.length, num = "string" == typeof var2 ? var2.length : var2, strOrNum = var3, m4.var3 = var3;
})(m3 || (m3 = {}));

View File

@ -12,8 +12,8 @@ class A {
var objA = new A();
ANY2[0], objA.a, M.n, A.foo(), ANY2[0], objA.a, M.n;
z: ;
x: "object";
r: "function";
x: ;
r: ;
z: objA.a;
z: ;
z: M.n;

View File

@ -13,7 +13,7 @@ class A {
var M, objA = new A();
objA.a, foo(), A.foo(), foo(), objA.a;
z: ;
r: "function";
r: ;
z: ;
z: objA.a;
z: ;

View File

@ -11,8 +11,8 @@ class A {
var objA = new A();
objA.a, M.n, A.foo(), objA.a, M.n, objA.a, M.n;
z: ;
x: "object";
r: "function";
x: ;
r: ;
z: ;
z: objA.a;
z: ;

View File

@ -14,8 +14,8 @@ class A {
var objA = new A();
objA.a, M.n, foo(), A.foo(), STRING.charAt(0), foo(), objA.a, M.n;
z: ;
x: "object";
r: "function";
x: ;
r: ;
z: "";
z: objA.a;
z: ;

View File

@ -1,3 +1,3 @@
var NumberEnum, StringEnum, NumberEnum, StringEnum;
const u = void 0;
5 === u && u.toString(10), !0 === u || !1 === u, void 0 === u, null === u, u === symb, 42 !== u, 42 !== u, 42 == u, !0 == u, u == Object, u === aString, u === aBoolean, u === aNumber, u === anObject, u === anObjectLiteral, u === aUnion, u === anIntersection, u === aFunction, (NumberEnum = NumberEnum || (NumberEnum = {}))[NumberEnum.A = 0] = "A", NumberEnum[NumberEnum.B = 1] = "B", NumberEnum[NumberEnum.C = 2] = "C", (StringEnum = StringEnum || (StringEnum = {})).A = "A", StringEnum.B = "B", StringEnum.C = "C", u === NumberEnum || u === StringEnum, u === NumberEnum.A, u === StringEnum.B;
5 === u && u.toString(10), !0 === u || !1 === u, (NumberEnum = NumberEnum || (NumberEnum = {}))[NumberEnum.A = 0] = "A", NumberEnum[NumberEnum.B = 1] = "B", NumberEnum[NumberEnum.C = 2] = "C", (StringEnum = StringEnum || (StringEnum = {})).A = "A", StringEnum.B = "B", StringEnum.C = "C", u === NumberEnum || u === StringEnum, NumberEnum.A, StringEnum.B;

View File

@ -1,2 +1,2 @@
var NumberEnum, StringEnum, NumberEnum, StringEnum, u = void 0;
5 === u && u.toString(10), !0 === u || !1 === u, void 0 === u, null === u, u === symb, 42 !== u, 42 !== u, 42 == u, !0 == u, u == Object, u === aString, u === aBoolean, u === aNumber, u === anObject, u === anObjectLiteral, u === aUnion, u === anIntersection, u === aFunction, (NumberEnum = NumberEnum || (NumberEnum = {}))[NumberEnum.A = 0] = "A", NumberEnum[NumberEnum.B = 1] = "B", NumberEnum[NumberEnum.C = 2] = "C", (StringEnum = StringEnum || (StringEnum = {})).A = "A", StringEnum.B = "B", StringEnum.C = "C", u === NumberEnum || u === StringEnum, u === NumberEnum.A, u === StringEnum.B;
5 === u && u.toString(10), !0 === u || !1 === u, (NumberEnum = NumberEnum || (NumberEnum = {}))[NumberEnum.A = 0] = "A", NumberEnum[NumberEnum.B = 1] = "B", NumberEnum[NumberEnum.C = 2] = "C", (StringEnum = StringEnum || (StringEnum = {})).A = "A", StringEnum.B = "B", StringEnum.C = "C", u === NumberEnum || u === StringEnum, NumberEnum.A, StringEnum.B;

View File

@ -47,17 +47,22 @@ where
///
/// Returns true if something is modified.
fn drop_return_value(&mut self, stmts: &mut Vec<Stmt>) -> bool {
// TODO(kdy1): (maybe) run optimization again if it's removed.
for s in stmts.iter_mut() {
if let Stmt::Return(ReturnStmt {
arg: arg @ Some(..),
..
}) = s
{
self.ignore_return_value(arg.as_deref_mut().unwrap());
self.ignore_return_value(
arg.as_deref_mut().unwrap(),
DropOpts {
drop_zero: true,
drop_str_lit: true,
},
);
if let Some(Expr::Invalid(..)) = arg.as_deref() {
self.changed = true;
*arg = None;
}
}
@ -125,7 +130,7 @@ where
}
}
pub(super) fn ignore_return_value(&mut self, e: &mut Expr) {
pub(super) fn ignore_return_value(&mut self, e: &mut Expr, opts: DropOpts) {
if self.options.unused {
if let Expr::Lit(Lit::Num(n)) = e {
// Skip 0
@ -139,6 +144,14 @@ where
if self.options.unused || self.options.side_effects {
match e {
Expr::Lit(Lit::Num(n)) => {
if n.value == 0.0 && opts.drop_zero {
self.changed = true;
*e = Expr::Invalid(Invalid { span: DUMMY_SP });
return;
}
}
Expr::Lit(Lit::Null(..) | Lit::BigInt(..) | Lit::Bool(..) | Lit::Regex(..))
| Expr::Ident(..) => {
self.changed = true;
@ -160,22 +173,62 @@ where
| op!("|")
| op!(">>")
| op!("<<")
| op!(">>>"),
| op!(">>>")
| op!("===")
| op!("!==")
| op!("==")
| op!("!=")
| op!("<")
| op!("<=")
| op!(">")
| op!(">="),
..
},
) => {
self.ignore_return_value(&mut bin.left);
self.ignore_return_value(&mut bin.right);
self.ignore_return_value(
&mut bin.left,
DropOpts {
drop_zero: true,
drop_str_lit: true,
},
);
self.ignore_return_value(
&mut bin.right,
DropOpts {
drop_zero: true,
drop_str_lit: true,
},
);
if bin.left.is_invalid() && bin.right.is_invalid() {
*e = Expr::Invalid(Invalid { span: DUMMY_SP });
return;
} else if bin.right.is_invalid() {
*e = *bin.left.take();
return;
} else if bin.left.is_invalid() {
*e = *bin.right.take();
return;
}
}
return;
Expr::Unary(UnaryExpr {
op: op!("void") | op!("typeof") | op!(unary, "+") | op!(unary, "-"),
arg,
..
}) => {
self.ignore_return_value(
&mut **arg,
DropOpts {
drop_str_lit: true,
drop_zero: true,
},
);
if arg.is_invalid() {
*e = Expr::Invalid(Invalid { span: DUMMY_SP });
return;
}
}
_ => {}
@ -184,7 +237,11 @@ where
match e {
Expr::Lit(Lit::Str(s)) => {
if s.value.starts_with("@swc/helpers") || s.value.starts_with("@babel/helpers") {
if opts.drop_str_lit
|| (s.value.starts_with("@swc/helpers")
|| s.value.starts_with("@babel/helpers"))
{
self.changed = true;
*e = Expr::Invalid(Invalid { span: DUMMY_SP });
}
}
@ -194,7 +251,13 @@ where
if let Some(last) = e.exprs.last_mut() {
// Non-last elements are already processed.
self.ignore_return_value(&mut **last);
self.ignore_return_value(&mut **last, opts);
}
let len = e.exprs.len();
e.exprs.retain(|e| !e.is_invalid());
if e.exprs.len() != len {
self.changed = true;
}
}
@ -221,3 +284,9 @@ where
}
}
}
#[derive(Debug, Default, Clone, Copy)]
pub(super) struct DropOpts {
pub drop_zero: bool,
pub drop_str_lit: bool,
}

View File

@ -1,4 +1,4 @@
use self::ctx::Ctx;
use self::{ctx::Ctx, misc::DropOpts};
use crate::{
debug::{dump, AssertValid},
marks::Marks,
@ -285,7 +285,13 @@ where
fn visit_mut_expr_stmt(&mut self, s: &mut ExprStmt) {
s.visit_mut_children_with(self);
self.ignore_return_value(&mut s.expr);
self.ignore_return_value(
&mut s.expr,
DropOpts {
drop_zero: true,
drop_str_lit: false,
},
);
}
fn visit_mut_exprs(&mut self, exprs: &mut Vec<Box<Expr>>) {
@ -414,7 +420,7 @@ where
self.optimize_arrow_method_prop(p);
if cfg!(feature = "debug") && cfg!(debug_assertions) {
if cfg!(debug_assertions) {
p.visit_with(&mut AssertValid);
}
}
@ -460,11 +466,21 @@ where
let is_last = idx == len - 1;
if !is_last {
self.ignore_return_value(&mut **e);
self.ignore_return_value(
&mut **e,
DropOpts {
drop_zero: false,
drop_str_lit: true,
},
);
}
}
e.exprs.retain(|e| !e.is_invalid());
if cfg!(debug_assertions) {
e.visit_with(&mut AssertValid);
}
}
fn visit_mut_stmt(&mut self, s: &mut Stmt) {
@ -500,27 +516,21 @@ where
}
if self.options.drop_debugger {
match s {
Stmt::Debugger(..) => {
self.changed = true;
*s = Stmt::Empty(EmptyStmt { span: DUMMY_SP });
tracing::debug!("drop_debugger: Dropped a debugger statement");
return;
}
_ => {}
if let Stmt::Debugger(..) = s {
self.changed = true;
*s = Stmt::Empty(EmptyStmt { span: DUMMY_SP });
tracing::debug!("drop_debugger: Dropped a debugger statement");
return;
}
}
self.loop_to_for_stmt(s);
match s {
Stmt::Expr(es) => {
if es.expr.is_invalid() {
*s = Stmt::Empty(EmptyStmt { span: DUMMY_SP });
return;
}
if let Stmt::Expr(es) = s {
if es.expr.is_invalid() {
*s = Stmt::Empty(EmptyStmt { span: DUMMY_SP });
return;
}
_ => {}
}
if cfg!(feature = "debug") && self.debug_infinite_loop {
@ -531,7 +541,7 @@ where
}
}
if cfg!(feature = "debug") && cfg!(debug_assertions) {
if cfg!(debug_assertions) {
s.visit_with(&mut AssertValid);
}
}
@ -546,7 +556,7 @@ where
_ => true,
});
if cfg!(feature = "debug") && cfg!(debug_assertions) {
if cfg!(debug_assertions) {
items.visit_with(&mut AssertValid);
}
}

View File

@ -9756,7 +9756,7 @@
function createHashHistory(props) {
void 0 === props && (props = {}), canUseDOM || (0, tiny_invariant_esm.default)(!1);
var globalHistory = window.history;
-1 === window.navigator.userAgent.indexOf("Firefox");
window.navigator.userAgent.indexOf("Firefox");
var _props = props, _props$getUserConfirm = _props.getUserConfirmation, getUserConfirmation = void 0 === _props$getUserConfirm ? getConfirmation : _props$getUserConfirm, _props$hashType = _props.hashType, basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : "", _HashPathCoders$hashT = HashPathCoders[void 0 === _props$hashType ? "slash" : _props$hashType], encodePath = _HashPathCoders$hashT.encodePath, decodePath = _HashPathCoders$hashT.decodePath;
function getDOMLocation() {
var path = decodePath(getHashPath());
@ -13869,7 +13869,7 @@
}, b.memoizedState = si, b.lanes = 33554432, a) : ((c = vi({
mode: "visible",
children: a
}, b.mode, c, null)).return = b, b.child = c) : (null !== a.memoizedState, f ? (d = wi(a, b, d.children, d.fallback, c), f = b.child, e = a.child.memoizedState, f.memoizedState = null === e ? {
}, b.mode, c, null)).return = b, b.child = c) : (a.memoizedState, f ? (d = wi(a, b, d.children, d.fallback, c), f = b.child, e = a.child.memoizedState, f.memoizedState = null === e ? {
baseLanes: c
} : {
baseLanes: e.baseLanes | c

View File

@ -377,7 +377,7 @@
}, parsedArea = Object.keys(area).reduce(function(result, key) {
var value, parsed = {
value: parseFloat(value = area[key]),
unit: (value.indexOf("%") === value.length - 1, "%")
unit: (value.indexOf("%") === value.length, "%")
}, calculated = _dimensionsConverters[key](parsed, context);
return result[key] = calculated, result;
}, {});

View File

@ -6704,14 +6704,14 @@
didReceiveUpdate = !0;
}
function bailoutOnAlreadyFinishedWork(current5, workInProgress7, renderLanes) {
return (null !== current5 && (workInProgress7.dependencies = current5.dependencies), stopProfilerTimerIfRunning(), markSkippedUpdateLanes(workInProgress7.lanes), includesSomeLane(renderLanes, workInProgress7.childLanes)) ? ((function(current, workInProgress) {
return (null !== current5 && (workInProgress7.dependencies = current5.dependencies), stopProfilerTimerIfRunning(), markSkippedUpdateLanes(workInProgress7.lanes), includesSomeLane(renderLanes, workInProgress7.childLanes)) ? (!function(current, workInProgress) {
if (!(null === current || workInProgress.child === current.child)) throw Error("Resuming work not yet implemented.");
if (null !== workInProgress.child) {
var currentChild = workInProgress.child, newChild = createWorkInProgress(currentChild, currentChild.pendingProps);
for(workInProgress.child = newChild, newChild.return = workInProgress; null !== currentChild.sibling;)currentChild = currentChild.sibling, (newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps)).return = workInProgress;
newChild.sibling = null;
}
})(current5, workInProgress7), workInProgress7.child) : null;
}(current5, workInProgress7), workInProgress7.child) : null;
}
function beginWork(current13, workInProgress16, renderLanes12) {
var updateLanes1 = workInProgress16.lanes;

View File

@ -31,6 +31,7 @@
"compiliation",
"cond",
"Cond",
"conds",
"constness",
"consts",
"corejs",
@ -142,6 +143,7 @@
"Unexported",
"Unexporter",
"unimpl",
"unsafes",
"untrusted",
"variadic",
"vercel"