diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-05-19 05:45:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-19 05:45:14 +0800 |
commit | 4fc39d8dadcec807be9d80ceb1d585f41b20c961 (patch) | |
tree | aa798fa8d4438e3265502dcc4a92f434f7c5cdc2 /lib | |
parent | 0b7c70f7260fc48023aa6e1685f35547b1cca6f2 (diff) | |
download | tracifyjs-4fc39d8dadcec807be9d80ceb1d585f41b20c961.tar.gz tracifyjs-4fc39d8dadcec807be9d80ceb1d585f41b20c961.zip |
fix corner case in `collapse_vars` (#3139)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js index 5f35b98a..efc7c47f 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1240,7 +1240,10 @@ merge(Compressor.prototype, { } function should_stop(node, parent) { - if (node instanceof AST_Assign) return node.operator != "=" && lhs.equivalent_to(node.left); + if (parent instanceof AST_For) return node !== parent.init; + if (node instanceof AST_Assign) { + return node.operator != "=" && lhs.equivalent_to(node.left); + } if (node instanceof AST_Call) { return lhs instanceof AST_PropAccess && lhs.equivalent_to(node.expression); } @@ -1249,7 +1252,6 @@ merge(Compressor.prototype, { if (node instanceof AST_LoopControl) return true; if (node instanceof AST_Try) return true; if (node instanceof AST_With) return true; - if (parent instanceof AST_For) return node !== parent.init; if (replace_all) return false; return node instanceof AST_SymbolRef && !node.is_declared(compressor); } |