diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-03-14 16:05:56 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-14 16:05:56 +0800 |
commit | ebd82b3fb6773f1985752550254a2effcc70b4af (patch) | |
tree | 59eb185aa9083de6699f49e4d37b23411d4d08c7 /lib/compress.js | |
parent | d074aa6e27de77bc60e69b933f90725931c8d5df (diff) | |
download | tracifyjs-ebd82b3fb6773f1985752550254a2effcc70b4af.tar.gz tracifyjs-ebd82b3fb6773f1985752550254a2effcc70b4af.zip |
fix corner case in `collapse_vars` (#3334)
fixes #3274
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/compress.js b/lib/compress.js index 2ccf330d..04adb8b2 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1585,13 +1585,19 @@ merge(Compressor.prototype, { var found = false; return statements[stat_index].transform(new TreeTransformer(function(node, descend, in_list) { if (found) return node; - if (node === expr || node.body === expr) { + if (node !== expr && node.body !== expr) return; + if (node instanceof AST_VarDef) { found = true; - if (node instanceof AST_VarDef) { - node.value = null; - return node; - } - return in_list ? MAP.skip : null; + node.value = null; + return node; + } + if (in_list) { + found = true; + return MAP.skip; + } + if (!this.parent()) { + found = true; + return null; } }, function(node) { if (node instanceof AST_Sequence) switch (node.expressions.length) { |