fix corner cases in unused (#3519)

This commit is contained in:
Alex Lam S.L
2019-10-23 06:46:05 +08:00
committed by GitHub
parent 267bc70d33
commit 4240fba9b8
2 changed files with 62 additions and 2 deletions

View File

@@ -3738,7 +3738,7 @@ merge(Compressor.prototype, {
head.push(def);
} else {
var value = def.value
&& (sym.references.length != 1 || !sym.replaced)
&& !def.value.single_use
&& def.value.drop_side_effect_free(compressor);
if (value) {
AST_Node.warn("Side effects in initialization of unused variable {name} [{file}:{line},{col}]", template(def.name));
@@ -6158,6 +6158,7 @@ merge(Compressor.prototype, {
if (single_use && fixed) {
def.single_use = false;
fixed._squeezed = true;
fixed.single_use = true;
if (fixed instanceof AST_Defun) {
fixed = make_node(AST_Function, fixed, fixed);
fixed.name = make_node(AST_SymbolLambda, fixed.name, fixed.name);