aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-03-25 03:18:36 +0800
committerGitHub <noreply@github.com>2017-03-25 03:18:36 +0800
commita30092e20f6a1e23706f87ca998121b8832a57bb (patch)
treebee9a34ae1e686ee724f3e2662e5a808e7f780d7 /lib
parentb1abe92e1aface2ec3d1c3666f8674e120f3b487 (diff)
downloadtracifyjs-a30092e20f6a1e23706f87ca998121b8832a57bb.tar.gz
tracifyjs-a30092e20f6a1e23706f87ca998121b8832a57bb.zip
fix invalid `AST_For.init` (#1657)
Turns out the only place in `Compressor` which can generate invalid `AST_For.init` is within `drop_unused()`, so focus the fix-up efforts. supercedes #1652 fixes #1656
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index e13985ee..ab7cca6f 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1961,6 +1961,9 @@ merge(Compressor.prototype, {
return in_list ? MAP.splice(body) : make_node(AST_BlockStatement, node, {
body: body
});
+ } else if (is_empty(node.init)) {
+ node.init = null;
+ return node;
}
}
if (node instanceof AST_Scope && node !== self)
@@ -2327,7 +2330,6 @@ merge(Compressor.prototype, {
};
OPT(AST_For, function(self, compressor){
- if (is_empty(self.init)) self.init = null;
if (!compressor.option("loops")) return self;
if (self.condition) {
var cond = self.condition.evaluate(compressor);