fix corner case in switch (#1765)

This commit is contained in:
Alex Lam S.L
2017-04-02 17:07:20 +08:00
committed by GitHub
parent d57527697f
commit 9469c03ac9
2 changed files with 31 additions and 4 deletions

View File

@@ -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 {