aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-02-13 18:24:57 +0000
committerGitHub <noreply@github.com>2021-02-14 02:24:57 +0800
commita6bb66931bfdd04d6ce05b640d89a8deff7ca3de (patch)
tree27f9d8b8b4d04ebab385bdd7f7f60b18422eeae1
parent766742e1d35027a3ef4a99115c3fc9fabd212537 (diff)
downloadtracifyjs-a6bb66931bfdd04d6ce05b640d89a8deff7ca3de.tar.gz
tracifyjs-a6bb66931bfdd04d6ce05b640d89a8deff7ca3de.zip
improve fix for #4325 (#4649)
-rw-r--r--lib/compress.js2
-rw-r--r--test/compress/functions.js4
-rw-r--r--test/compress/keep_fargs.js2
-rw-r--r--test/compress/loops.js2
-rw-r--r--test/compress/rests.js24
-rw-r--r--test/compress/side_effects.js6
-rw-r--r--test/mocha/reduce.js3
7 files changed, 21 insertions, 22 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 38d25b15..7e113ecc 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -7003,6 +7003,8 @@ merge(Compressor.prototype, {
// always shallow clone to ensure stripping of negated IIFEs
self = self.clone();
self.expression = exp.clone();
+ // avoid extraneous traversal
+ if (exp._squeezed) self.expression._squeezed = true;
}
if (self instanceof AST_New) {
var fn = exp;
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 5de05f61..77dd256e 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -3322,7 +3322,9 @@ issue_3506_1: {
}
expect: {
var a = "FAIL";
- a && (a = "PASS");
+ !function(b) {
+ b && (a = "PASS");
+ }(a);
console.log(a);
}
expect_stdout: "PASS"
diff --git a/test/compress/keep_fargs.js b/test/compress/keep_fargs.js
index d5d7ef93..4c1c1b7d 100644
--- a/test/compress/keep_fargs.js
+++ b/test/compress/keep_fargs.js
@@ -438,7 +438,7 @@ issue_2506: {
function f0(bar) {
(function() {
(function() {
- if (false <= NaN & this >> 1 >= 0)
+ if (false <= 0/0 & this >> 1 >= 0)
c++;
})(c++);
})();
diff --git a/test/compress/loops.js b/test/compress/loops.js
index 3217afd4..0afffae5 100644
--- a/test/compress/loops.js
+++ b/test/compress/loops.js
@@ -1067,7 +1067,6 @@ issue_4084: {
options = {
keep_fargs: false,
loops: true,
- passes: 2,
reduce_vars: true,
unused: true,
}
@@ -1276,6 +1275,7 @@ issue_4355: {
dead_code: true,
evaluate: true,
loops: true,
+ passes: 2,
side_effects: true,
unused: true,
}
diff --git a/test/compress/rests.js b/test/compress/rests.js
index 59e29457..676b5e7f 100644
--- a/test/compress/rests.js
+++ b/test/compress/rests.js
@@ -673,27 +673,21 @@ issue_4575: {
unused: true,
}
input: {
- A = "PASS";
- (function() {
- var a = 0, b = a;
- var c = function a(...b) {
- A;
- var d = A;
- console.log(d, b.length);
+ (function(a) {
+ var b = a;
+ var c = function a(...d) {
+ console.log(d.length);
}();
})();
}
expect: {
- A = "PASS";
- (function() {
- (function(b) {
- A;
- var d = A;
- console.log(d, b.length);
- })([]);
+ (function(a) {
+ (function a(...d) {
+ console.log(d.length);
+ })();
})();
}
- expect_stdout: "PASS 0"
+ expect_stdout: "0"
node_version: ">=6"
}
diff --git a/test/compress/side_effects.js b/test/compress/side_effects.js
index 2a65bc24..177cf503 100644
--- a/test/compress/side_effects.js
+++ b/test/compress/side_effects.js
@@ -458,14 +458,14 @@ issue_4325: {
}
expect: {
(function() {
- (function() {
+ (function(c) {
try {
- (void 0).p = 0;
+ c.p = 0;
} catch (e) {
console.log("PASS");
return;
}
- })();
+ })(void 0);
})();
}
expect_stdout: "PASS"
diff --git a/test/mocha/reduce.js b/test/mocha/reduce.js
index 587aa7be..9e3fc8be 100644
--- a/test/mocha/reduce.js
+++ b/test/mocha/reduce.js
@@ -294,8 +294,9 @@ describe("test/reduce.js", function() {
"// }",
]).join("\n"));
});
- it("Should maintain block-scope for const & let", function() {
+ it("Should maintain block-scope for const/let", function() {
if (semver.satisfies(process.version, "<4")) return;
+ this.timeout(120000);
var code = [
'"use strict";',
"",