fix corner case in unused (#3517)

fixes #3515
This commit is contained in:
Alex Lam S.L
2019-10-23 01:58:40 +08:00
committed by GitHub
parent a53ab99378
commit 267bc70d33
2 changed files with 28 additions and 1 deletions

View File

@@ -3737,7 +3737,9 @@ merge(Compressor.prototype, {
def.value = null;
head.push(def);
} else {
var value = def.value && def.value.drop_side_effect_free(compressor);
var value = def.value
&& (sym.references.length != 1 || !sym.replaced)
&& 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));
side_effects.push(value);