Skip to content

Commit

Permalink
fix corner case in side_effects (#5024)
Browse files Browse the repository at this point in the history
fixes #5023
  • Loading branch information
alexlamsl committed Jun 22, 2021
1 parent 7c5b6f3 commit 95090db
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
46 changes: 46 additions & 0 deletions test/compress/awaits.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 95090db

Please sign in to comment.