improve fix for #4325 (#4649)

This commit is contained in:
Alex Lam S.L
2021-02-13 18:24:57 +00:00
committed by GitHub
parent 766742e1d3
commit a6bb66931b
7 changed files with 21 additions and 22 deletions

View File

@@ -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;

View File

@@ -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"

View File

@@ -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++);
})();

View File

@@ -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,
}

View File

@@ -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"
}

View File

@@ -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"

View File

@@ -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";',
"",