fix corner case in loops & unused (#4241)

fixes #4240
This commit is contained in:
Alex Lam S.L
2020-10-24 06:33:48 +01:00
committed by GitHub
parent ff38d2471f
commit c5df8355ba
2 changed files with 33 additions and 1 deletions

View File

@@ -5182,7 +5182,7 @@ merge(Compressor.prototype, {
var def = sym.definition();
if (!def) return;
if (def.id in in_use_ids) return;
if (def.scope !== self && member(def, self.enclosed)) return;
if (def.scope !== self && self.find_variable(sym) === def) return;
log(sym, "Dropping unused loop variable {name}");
if (for_ins[def.id] === node) delete for_ins[def.id];
var body = [];