diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-04-02 17:07:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-02 17:07:20 +0800 |
commit | 9469c03ac976b3cfc1e52abf034ce76f1d6aca59 (patch) | |
tree | 05d5d5df8658191e2da841f01142e9279f73224d /lib | |
parent | d57527697fba37bfad50ca0283326a458cdea031 (diff) | |
download | tracifyjs-9469c03ac976b3cfc1e52abf034ce76f1d6aca59.tar.gz tracifyjs-9469c03ac976b3cfc1e52abf034ce76f1d6aca59.zip |
fix corner case in `switch` (#1765)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/compress.js b/lib/compress.js index 763490a7..79e7d4d2 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2557,7 +2557,7 @@ merge(Compressor.prototype, { if (!default_branch) { default_branch = branch; } else { - eliminate_branch(branch); + eliminate_branch(branch, body[body.length - 1]); } } else if (value !== self.expression) { var exp = branch.expression.evaluate(compressor); @@ -2570,7 +2570,7 @@ merge(Compressor.prototype, { default_branch = null; } } else if (exp !== branch.expression) { - eliminate_branch(branch); + eliminate_branch(branch, body[body.length - 1]); continue; } } @@ -2583,7 +2583,7 @@ merge(Compressor.prototype, { } body.push(branch); } - while (i < len) eliminate_branch(self.body[i++]); + while (i < len) eliminate_branch(self.body[i++], body[body.length - 1]); if (body.length > 0) { body[0].body = decl.concat(body[0].body); } @@ -2626,7 +2626,6 @@ merge(Compressor.prototype, { return self; function eliminate_branch(branch, prev) { - if (!prev) prev = body[body.length - 1]; if (prev && !aborts(prev)) { prev.body = prev.body.concat(branch.body); } else { |