has_side_effects() should take AST_Switch.expression into account (#1699)
fixes #1698
This commit is contained in:
@@ -1610,9 +1610,13 @@ 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_Switch, function(compressor){
|
||||||
|
return this.expression.has_side_effects(compressor)
|
||||||
|
|| any(this.body, compressor);
|
||||||
|
});
|
||||||
def(AST_Case, function(compressor){
|
def(AST_Case, function(compressor){
|
||||||
return any(this.body, compressor)
|
return this.expression.has_side_effects(compressor)
|
||||||
|| this.expression.has_side_effects(compressor);
|
|| any(this.body, compressor);
|
||||||
});
|
});
|
||||||
def(AST_Try, function(compressor){
|
def(AST_Try, function(compressor){
|
||||||
return any(this.body, compressor)
|
return any(this.body, compressor)
|
||||||
|
|||||||
@@ -593,3 +593,24 @@ if_switch_typeof: {
|
|||||||
a;
|
a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_1698: {
|
||||||
|
options = {
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 1;
|
||||||
|
!function() {
|
||||||
|
switch (a++) {}
|
||||||
|
}();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 1;
|
||||||
|
!function() {
|
||||||
|
switch (a++) {}
|
||||||
|
}();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "2"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user