aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-01-05 06:23:46 +0000
committerGitHub <noreply@github.com>2021-01-05 14:23:46 +0800
commitfc5aee662d99257f59830ebcd5053ead48c9039b (patch)
treee8a6ad88390fec0e48916b10a5044ad56d2f54b7 /lib/compress.js
parent5fbbb43839d010ec609da3bf15308cb5b6f74dc5 (diff)
downloadtracifyjs-fc5aee662d99257f59830ebcd5053ead48c9039b.tar.gz
tracifyjs-fc5aee662d99257f59830ebcd5053ead48c9039b.zip
fix corner case in `merge_vars` (#4505)
fixes #4504
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/compress.js b/lib/compress.js
index aedbe448..1934ca3d 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -4944,16 +4944,15 @@ merge(Compressor.prototype, {
if (node instanceof AST_DestructuredKeyVal) {
if (node.key instanceof AST_Node) {
push();
+ segment.block = node;
node.key.walk(tw);
- pop();
- push();
node.value.walk(marker);
pop();
} else {
node.value.walk(marker);
}
} else if (node instanceof AST_SymbolRef) {
- mark(node, false, true);
+ mark(node);
} else {
node.walk(tw);
}
@@ -4963,9 +4962,9 @@ merge(Compressor.prototype, {
return true;
}
if (lhs instanceof AST_SymbolRef) {
- if (node.operator != "=") mark(lhs, true, false);
+ if (node.operator != "=") mark(lhs, true);
node.right.walk(tw);
- mark(lhs, false, true);
+ mark(lhs);
return true;
}
return;
@@ -5073,7 +5072,7 @@ merge(Compressor.prototype, {
var marker = node.uses_arguments && !tw.has_directive("use strict") ? function(node) {
if (node instanceof AST_SymbolFunarg) references[node.definition().id] = false;
} : function(node) {
- if (node instanceof AST_SymbolFunarg) mark(node, false, true);
+ if (node instanceof AST_SymbolFunarg) mark(node);
};
var scanner = new TreeWalker(function(ref) {
if (ref instanceof AST_SymbolDeclaration) references[ref.definition().id] = false;
@@ -5088,7 +5087,7 @@ merge(Compressor.prototype, {
} else {
var save = segment;
pop();
- mark(ref, true, false);
+ mark(ref, true);
segment = save;
}
return true;
@@ -5125,7 +5124,7 @@ merge(Compressor.prototype, {
return true;
}
if (node instanceof AST_SymbolRef) {
- mark(node, true, false);
+ mark(node, true);
return true;
}
if (node instanceof AST_Try) {
@@ -5153,7 +5152,7 @@ merge(Compressor.prototype, {
if (!UNARY_POSTFIX[node.operator]) return;
var sym = node.expression;
if (!(sym instanceof AST_SymbolRef)) return;
- mark(sym, true, true);
+ mark(sym, true);
return true;
}
if (node instanceof AST_VarDef) {
@@ -5161,7 +5160,7 @@ merge(Compressor.prototype, {
node.name.mark_symbol(node.value ? function(node) {
if (!(node instanceof AST_SymbolDeclaration)) return;
if (node instanceof AST_SymbolVar) {
- mark(node, false, true);
+ mark(node, false);
} else {
references[node.definition().id] = false;
}
@@ -5246,7 +5245,7 @@ merge(Compressor.prototype, {
segment = Object.getPrototypeOf(segment);
}
- function mark(sym, read, write) {
+ function mark(sym, read) {
var def = sym.definition(), ldef;
if (def.id in references) {
var refs = references[def.id];