fix side-effects detection on switch statements (#1678)
extension of #1675
This commit is contained in:
@@ -1610,6 +1610,10 @@ merge(Compressor.prototype, {
|
|||||||
def(AST_Block, function(compressor){
|
def(AST_Block, function(compressor){
|
||||||
return any(this.body, compressor);
|
return any(this.body, compressor);
|
||||||
});
|
});
|
||||||
|
def(AST_Case, function(compressor){
|
||||||
|
return any(this.body, compressor)
|
||||||
|
|| this.expression.has_side_effects(compressor);
|
||||||
|
});
|
||||||
def(AST_Try, function(compressor){
|
def(AST_Try, function(compressor){
|
||||||
return any(this.body, compressor)
|
return any(this.body, compressor)
|
||||||
|| this.bcatch && this.bcatch.has_side_effects(compressor)
|
|| this.bcatch && this.bcatch.has_side_effects(compressor)
|
||||||
|
|||||||
@@ -125,3 +125,35 @@ side_effects_label: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
side_effects_switch: {
|
||||||
|
options = {
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
function g() {
|
||||||
|
switch (0) {
|
||||||
|
default:
|
||||||
|
case console.log("PASS"):
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g();
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f() {
|
||||||
|
(function() {
|
||||||
|
switch (0) {
|
||||||
|
default:
|
||||||
|
case console.log("PASS"):
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user