aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-02-24 18:17:28 +0000
committerGitHub <noreply@github.com>2021-02-25 02:17:28 +0800
commitb8672b55b25b3333188724a5c20588db96ccd0dc (patch)
treeaebbef363562062fa002a108b2a2db81a19438f5 /lib
parenta5a958beda5e0e7daedd5bd0cb4c72a81aade19b (diff)
downloadtracifyjs-b8672b55b25b3333188724a5c20588db96ccd0dc.tar.gz
tracifyjs-b8672b55b25b3333188724a5c20588db96ccd0dc.zip
fix corner case in `unused` (#4682)
fixes #4681
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 93023e19..263bad01 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -5743,7 +5743,10 @@ merge(Compressor.prototype, {
if (prop.key instanceof AST_Node) prop.key.walk(tw);
if (!prop.value) return;
if (is_export || prop instanceof AST_ClassField && prop.static) {
+ var save_scope = scope;
+ scope = node;
prop.value.walk(tw);
+ scope = save_scope;
} else {
initializations.add(def.id, prop.value);
}
@@ -5793,6 +5796,12 @@ merge(Compressor.prototype, {
assignments.add(def.id, node);
return true;
}
+ } else if (node instanceof AST_This && scope instanceof AST_DefClass) {
+ var def = scope.name.definition();
+ if (!(def.id in in_use_ids)) {
+ in_use_ids[def.id] = true;
+ in_use.push(def);
+ }
}
return scan_ref_scoped(node, descend, true);
});