@@ -1414,11 +1414,18 @@ merge(Compressor.prototype, {
|
|||||||
body: self.expression
|
body: self.expression
|
||||||
}).transform(compressor);
|
}).transform(compressor);
|
||||||
}
|
}
|
||||||
var last_branch = self.body[self.body.length - 1];
|
for(;;) {
|
||||||
if (last_branch) {
|
var last_branch = self.body[self.body.length - 1];
|
||||||
var stat = last_branch.body[last_branch.body.length - 1]; // last statement
|
if (last_branch) {
|
||||||
if (stat instanceof AST_Break && loop_body(compressor.loopcontrol_target(stat.label)) === self)
|
var stat = last_branch.body[last_branch.body.length - 1]; // last statement
|
||||||
last_branch.body.pop();
|
if (stat instanceof AST_Break && loop_body(compressor.loopcontrol_target(stat.label)) === self)
|
||||||
|
last_branch.body.pop();
|
||||||
|
if (last_branch instanceof AST_Default && last_branch.body.length == 0) {
|
||||||
|
self.body.pop();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
var exp = self.expression.evaluate(compressor);
|
var exp = self.expression.evaluate(compressor);
|
||||||
out: if (exp.length == 2) try {
|
out: if (exp.length == 2) try {
|
||||||
|
|||||||
@@ -208,3 +208,53 @@ constant_switch_9: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drop_default_1: {
|
||||||
|
options = { dead_code: true };
|
||||||
|
input: {
|
||||||
|
switch (foo) {
|
||||||
|
case 'bar': baz();
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
switch (foo) {
|
||||||
|
case 'bar': baz();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
drop_default_2: {
|
||||||
|
options = { dead_code: true };
|
||||||
|
input: {
|
||||||
|
switch (foo) {
|
||||||
|
case 'bar': baz(); break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
switch (foo) {
|
||||||
|
case 'bar': baz();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
keep_default: {
|
||||||
|
options = { dead_code: true };
|
||||||
|
input: {
|
||||||
|
switch (foo) {
|
||||||
|
case 'bar': baz();
|
||||||
|
default:
|
||||||
|
something();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
switch (foo) {
|
||||||
|
case 'bar': baz();
|
||||||
|
default:
|
||||||
|
something();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user