aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-11-17 08:23:50 +0000
committerGitHub <noreply@github.com>2020-11-17 16:23:50 +0800
commit8a83c8dd46dc8e446cd7231116a06c8b217291b7 (patch)
treeb1f081551a1f9f488ac07d963ddbf41463dd50cd /lib
parent2a612fd472b4d26fee4342fb57fe9ec54ab124cb (diff)
downloadtracifyjs-8a83c8dd46dc8e446cd7231116a06c8b217291b7.tar.gz
tracifyjs-8a83c8dd46dc8e446cd7231116a06c8b217291b7.zip
fix corner cases in `collapse_vars` & `dead_code` (#4285)
fixes #4284
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/compress.js b/lib/compress.js
index b8725b32..e4426fa3 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -845,7 +845,7 @@ merge(Compressor.prototype, {
if (init instanceof AST_Definitions) {
init.definitions[0].name.match_symbol(function(node) {
if (node instanceof AST_SymbolDeclaration) node.definition().fixed = false;
- });
+ }, true);
} else if (init instanceof AST_SymbolRef) {
init.definition().fixed = false;
}
@@ -1188,11 +1188,12 @@ merge(Compressor.prototype, {
AST_Node.DEFMETHOD("match_symbol", function(predicate) {
return predicate(this);
});
- AST_Destructured.DEFMETHOD("match_symbol", function(predicate) {
+ AST_Destructured.DEFMETHOD("match_symbol", function(predicate, allow_computed_keys) {
var found = false;
var tw = new TreeWalker(function(node) {
if (found) return true;
if (node instanceof AST_DestructuredKeyVal) {
+ if (!allow_computed_keys && node.key instanceof AST_Node) return found = true;
node.value.walk(tw);
return true;
}
@@ -7045,7 +7046,7 @@ merge(Compressor.prototype, {
name: node,
value: make_value(compressor, node)
}));
- });
+ }, true);
});
return dropped;
};
@@ -7107,7 +7108,7 @@ merge(Compressor.prototype, {
if (node instanceof AST_SymbolDeclaration) {
return !node.fixed_value() || may_overlap(compressor, node.definition());
}
- });
+ }, true);
}) ? to_var(self) : self;
}
@@ -9061,6 +9062,7 @@ merge(Compressor.prototype, {
def.fixed = false;
return strip_assignment();
} else if (parent instanceof AST_VarDef) {
+ if (!(parent.name instanceof AST_SymbolDeclaration)) continue;
if (parent.name.definition() !== def) continue;
if (in_try(level, parent)) break;
def.fixed = false;