fix corner case in side_effects (#5024)

fixes #5023
This commit is contained in:
Alex Lam S.L
2021-06-22 17:36:07 +01:00
committed by GitHub
parent 7c5b6f349e
commit 95090dbf24
2 changed files with 47 additions and 1 deletions

View File

@@ -5275,7 +5275,7 @@ merge(Compressor.prototype, {
|| any(this.body, compressor);
});
def(AST_SymbolRef, function(compressor) {
return !this.is_declared(compressor);
return !this.is_declared(compressor) || !can_drop_symbol(this, compressor);
});
def(AST_Template, function(compressor) {
if (any(this.expressions, compressor)) return true;

View File

@@ -1869,3 +1869,49 @@ issue_5019_3: {
]
node_version: ">=8"
}
issue_5023_1: {
options = {
awaits: true,
reduce_vars: true,
side_effects: true,
}
input: {
(async function() {
let a = a;
})();
console.log("PASS");
}
expect: {
(async function() {
let a = a;
})();
console.log("PASS");
}
expect_stdout: "PASS"
node_version: ">=8"
}
issue_5023_2: {
options = {
awaits: true,
reduce_vars: true,
side_effects: true,
}
input: {
(async function() {
let a;
a = a;
})();
console.log("PASS");
}
expect: {
(function() {
let a;
a = a;
})();
console.log("PASS");
}
expect_stdout: "PASS"
node_version: ">=8"
}