diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-01-03 18:31:20 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-04 02:31:20 +0800 |
commit | df2cfcb5fcd7e4549df5015580c838138cd24130 (patch) | |
tree | 056108b00afb853a963119efdc1290bb5063110d /lib/compress.js | |
parent | 623a0d920f66656d7874a4bf005c24b44abb95a4 (diff) | |
download | tracifyjs-df2cfcb5fcd7e4549df5015580c838138cd24130.tar.gz tracifyjs-df2cfcb5fcd7e4549df5015580c838138cd24130.zip |
fix corner case in `evaluate` (#4501)
fixes #4500
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js index 538b906e..ca2880ec 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3894,7 +3894,13 @@ merge(Compressor.prototype, { if (node instanceof AST_Unary && UNARY_POSTFIX[node.operator]) modified(node.expression); }); function modified(node) { - if (node instanceof AST_PropAccess) { + if (node instanceof AST_DestructuredArray) { + node.elements.forEach(modified); + } else if (node instanceof AST_DestructuredObject) { + node.properties.forEach(function(prop) { + modified(prop.value); + }); + } else if (node instanceof AST_PropAccess) { modified(node.expression); } else if (node instanceof AST_SymbolRef) { node.definition().references.forEach(function(ref) { @@ -3928,7 +3934,6 @@ merge(Compressor.prototype, { if (!HOP(lhs, "_eval") && lhs instanceof AST_SymbolRef && lhs.fixed && lhs.definition().fixed) { node = lhs; } else if (op == "=") { - lhs.walk(scan_modified); node = this.right; } else { node = make_node(AST_Binary, this, { @@ -3937,6 +3942,7 @@ merge(Compressor.prototype, { right: this.right, }); } + lhs.walk(scan_modified); var value = node._eval(compressor, ignore_side_effects, cached, depth); if (typeof value == "object") return this; modified(lhs); @@ -4011,6 +4017,7 @@ merge(Compressor.prototype, { } var def = e instanceof AST_SymbolRef && e.definition(); if (!non_converting_unary[op] && !(def && def.fixed)) depth++; + e.walk(scan_modified); var v = e._eval(compressor, ignore_side_effects, cached, depth); if (v === e) { if (ignore_side_effects && op == "void") return; @@ -4054,6 +4061,7 @@ merge(Compressor.prototype, { } } if (!(e instanceof AST_SymbolRef && e.definition().fixed)) depth++; + e.walk(scan_modified); var v = e._eval(compressor, ignore_side_effects, cached, depth); if (v === e) return this; modified(e); |