diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-04-23 01:51:56 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-23 01:51:56 +0800 |
commit | 45ce3694807ee0daeb7e0f84c12ffbd8ca4f733c (patch) | |
tree | 7acd82d0f499a80dd2f75e3291c4abf13aed8c34 /lib | |
parent | ca32a09032b3e7d6aac1f0b01f67a0b67b3037f1 (diff) | |
download | tracifyjs-45ce3694807ee0daeb7e0f84c12ffbd8ca4f733c.tar.gz tracifyjs-45ce3694807ee0daeb7e0f84c12ffbd8ca4f733c.zip |
fix `AST_For.init` patch-up in `drop_unused()` (#1839)
fixes #1838
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index 22e012e9..5a8f23bf 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2066,6 +2066,7 @@ merge(Compressor.prototype, { // certain combination of unused name + side effect leads to: // https://github.com/mishoo/UglifyJS2/issues/44 // https://github.com/mishoo/UglifyJS2/issues/1830 + // https://github.com/mishoo/UglifyJS2/issues/1838 // that's an invalid AST. // We fix it at this stage by moving the `var` outside the `for`. if (node instanceof AST_For) { @@ -2075,6 +2076,8 @@ merge(Compressor.prototype, { node.init = block.body.pop(); block.body.push(node); return in_list ? MAP.splice(block.body) : block; + } else if (node.init instanceof AST_SimpleStatement) { + node.init = node.init.body; } else if (is_empty(node.init)) { node.init = null; } |