aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-11-18 21:44:47 +0000
committerGitHub <noreply@github.com>2020-11-19 05:44:47 +0800
commitaecbabc587247f65316988629d17aa29383f9156 (patch)
tree09ae36682cb966488728bb52dccc6ee30fe3cc9a /lib
parentfd6544b34011a30bd869d2447b744fe51d0d741f (diff)
downloadtracifyjs-aecbabc587247f65316988629d17aa29383f9156.tar.gz
tracifyjs-aecbabc587247f65316988629d17aa29383f9156.zip
fix corner case in `merge_vars` (#4302)
fixes #4301
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 0f1342f7..f0453d6a 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -4635,14 +4635,27 @@ merge(Compressor.prototype, {
var lhs = node.left;
if (lhs instanceof AST_Destructured) {
node.right.walk(tw);
- lhs.mark_symbol(function(node) {
- if (node instanceof AST_SymbolRef) {
+ var marker = new TreeWalker(function(node) {
+ if (node instanceof AST_Destructured) return;
+ if (node instanceof AST_DestructuredKeyVal) {
+ if (node.key instanceof AST_Node) {
+ push();
+ 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);
} else {
node.walk(tw);
}
return true;
- }, tw);
+ });
+ lhs.walk(marker);
return true;
}
if (lhs instanceof AST_SymbolRef) {