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 // always shallow clone to ensure stripping of negated IIFEs
self = self.clone(); self = self.clone();
self.expression = exp.clone(); self.expression = exp.clone();
// avoid extraneous traversal
if (exp._squeezed) self.expression._squeezed = true;
} }
if (self instanceof AST_New) { if (self instanceof AST_New) {
var fn = exp; var fn = exp;

View File

@@ -3322,7 +3322,9 @@ issue_3506_1: {
} }
expect: { expect: {
var a = "FAIL"; var a = "FAIL";
a && (a = "PASS"); !function(b) {
b && (a = "PASS");
}(a);
console.log(a); console.log(a);
} }
expect_stdout: "PASS" expect_stdout: "PASS"

View File

@@ -438,7 +438,7 @@ issue_2506: {
function f0(bar) { function f0(bar) {
(function() { (function() {
(function() { (function() {
if (false <= NaN & this >> 1 >= 0) if (false <= 0/0 & this >> 1 >= 0)
c++; c++;
})(c++); })(c++);
})(); })();

View File

@@ -1067,7 +1067,6 @@ issue_4084: {
options = { options = {
keep_fargs: false, keep_fargs: false,
loops: true, loops: true,
passes: 2,
reduce_vars: true, reduce_vars: true,
unused: true, unused: true,
} }
@@ -1276,6 +1275,7 @@ issue_4355: {
dead_code: true, dead_code: true,
evaluate: true, evaluate: true,
loops: true, loops: true,
passes: 2,
side_effects: true, side_effects: true,
unused: true, unused: true,
} }

View File

@@ -673,27 +673,21 @@ issue_4575: {
unused: true, unused: true,
} }
input: { input: {
A = "PASS"; (function(a) {
(function() { var b = a;
var a = 0, b = a; var c = function a(...d) {
var c = function a(...b) { console.log(d.length);
A;
var d = A;
console.log(d, b.length);
}(); }();
})(); })();
} }
expect: { expect: {
A = "PASS"; (function(a) {
(function() { (function a(...d) {
(function(b) { console.log(d.length);
A; })();
var d = A;
console.log(d, b.length);
})([]);
})(); })();
} }
expect_stdout: "PASS 0" expect_stdout: "0"
node_version: ">=6" node_version: ">=6"
} }

View File

@@ -458,14 +458,14 @@ issue_4325: {
} }
expect: { expect: {
(function() { (function() {
(function() { (function(c) {
try { try {
(void 0).p = 0; c.p = 0;
} catch (e) { } catch (e) {
console.log("PASS"); console.log("PASS");
return; return;
} }
})(); })(void 0);
})(); })();
} }
expect_stdout: "PASS" expect_stdout: "PASS"

View File

@@ -294,8 +294,9 @@ describe("test/reduce.js", function() {
"// }", "// }",
]).join("\n")); ]).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; if (semver.satisfies(process.version, "<4")) return;
this.timeout(120000);
var code = [ var code = [
'"use strict";', '"use strict";',
"", "",