aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-02-27 20:41:21 +0000
committerGitHub <noreply@github.com>2021-02-28 04:41:21 +0800
commitc549ee89b9a0641ea78f57472168963811c7e111 (patch)
tree8dc88b6d278e2f49c01ed6532dca0ff417bab9be /lib
parent7924a3ae8b7bb69c246215618768eda04987b91d (diff)
downloadtracifyjs-c549ee89b9a0641ea78f57472168963811c7e111.tar.gz
tracifyjs-c549ee89b9a0641ea78f57472168963811c7e111.zip
fix corner case `reduce_vars` (#4706)
fixes #4705
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js52
1 files changed, 28 insertions, 24 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 101fdb4e..ba7ab4a0 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -938,31 +938,35 @@ merge(Compressor.prototype, {
node.variables.each(function(def) {
reset_def(tw, compressor, def);
});
- if (!node.name) return;
- var d = node.name.definition();
- var parent = tw.parent();
- if (parent instanceof AST_ExportDeclaration || parent instanceof AST_ExportDefault) d.single_use = false;
- if (safe_to_assign(tw, d, true)) {
- mark(tw, d);
- tw.loop_ids[d.id] = tw.in_loop;
- d.fixed = function() {
- return node;
- };
- d.fixed.assigns = [ node ];
- if (!is_safe_lexical(d)) d.single_use = false;
- } else {
- d.fixed = false;
- }
- });
- def(AST_ClassField, function(tw) {
- var node = this;
- if (node.static) return;
- if (node.key instanceof AST_Node) node.key.walk(tw);
- if (node.value) {
- push(tw);
- node.value.walk(tw);
- pop(tw);
+ if (node.extends) node.extends.walk(tw);
+ if (node.name) {
+ var d = node.name.definition();
+ var parent = tw.parent();
+ if (parent instanceof AST_ExportDeclaration || parent instanceof AST_ExportDefault) d.single_use = false;
+ if (safe_to_assign(tw, d, true)) {
+ mark(tw, d);
+ tw.loop_ids[d.id] = tw.in_loop;
+ d.fixed = function() {
+ return node;
+ };
+ d.fixed.assigns = [ node ];
+ if (!is_safe_lexical(d)) d.single_use = false;
+ } else {
+ d.fixed = false;
+ }
}
+ node.properties.filter(function(prop) {
+ if (prop.key instanceof AST_Node) prop.key.walk(tw);
+ return prop.value;
+ }).forEach(function(prop) {
+ if (prop.static) {
+ prop.value.walk(tw);
+ } else {
+ push(tw);
+ prop.value.walk(tw);
+ pop(tw);
+ }
+ });
return true;
});
def(AST_Conditional, function(tw) {