aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-08-26 10:32:20 +0100
committerGitHub <noreply@github.com>2020-08-26 17:32:20 +0800
commit93d084a1d191379a55498a12f79f573e7bb1d1be (patch)
tree799f169714a73f3f1b4aae4d10efedd7642e5e57 /lib
parentc7a3e09407fbed928ccd874609c63c31b27f052a (diff)
downloadtracifyjs-93d084a1d191379a55498a12f79f573e7bb1d1be.tar.gz
tracifyjs-93d084a1d191379a55498a12f79f573e7bb1d1be.zip
fix corner case in `loops` & `unused` (#4076)
fixes #4075
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 213cead3..a1f3d50c 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -4677,7 +4677,9 @@ merge(Compressor.prototype, {
sym = sym.expression.tail_node();
}
var def = sym.definition();
- if (!def || def.id in in_use_ids) return;
+ if (!def) return;
+ if (def.scope !== self) return;
+ if (def.id in in_use_ids) return;
log(sym, "Dropping unused loop variable {name}");
var value = node.object.drop_side_effect_free(compressor);
if (!value) return in_list ? List.skip : make_node(AST_EmptyStatement, node);