diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-10-12 07:13:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-12 14:13:17 +0800 |
commit | b512726cf39066919483d2add87905f677db1832 (patch) | |
tree | 6369b4e358af75e9c17de03107d4503091fc2d64 /lib | |
parent | 9b7a13c8c7f06598b3da8da29da4e8e5680cd24e (diff) | |
download | tracifyjs-b512726cf39066919483d2add87905f677db1832.tar.gz tracifyjs-b512726cf39066919483d2add87905f677db1832.zip |
fix corner case in `collapse_vars` (#4199)
fixes #4197
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js index c4012031..fc65e426 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1599,9 +1599,13 @@ merge(Compressor.prototype, { } if (node instanceof AST_SymbolRef) { if (symbol_in_lvalues(node, parent)) { - return !parent || parent.operator != "=" || parent.left !== node; + return !(parent instanceof AST_Assign && parent.operator == "=" && parent.left === node); } - return side_effects && may_modify(node); + if (side_effects && may_modify(node)) return true; + var def = node.definition(); + return (in_try || def.scope.resolve() !== scope) && !all(def.orig, function(sym) { + return !(sym instanceof AST_SymbolConst); + }); } if (node instanceof AST_This) return symbol_in_lvalues(node, parent); if (node instanceof AST_VarDef) { |