Consider yield expressions as having side-effects

See #1043
This commit is contained in:
Richard van Velzen
2016-04-13 14:39:49 +02:00
parent 91cdb93e57
commit eaf3911c31
2 changed files with 31 additions and 3 deletions

View File

@@ -978,9 +978,7 @@ merge(Compressor.prototype, {
|| this.alternative.has_side_effects(compressor);
});
def(AST_Unary, function(compressor){
return this.operator == "delete"
|| this.operator == "++"
|| this.operator == "--"
return member(this.operator, ["delete", "++", "--", "yield", "yield*"])
|| this.expression.has_side_effects(compressor);
});
def(AST_SymbolRef, function(compressor){

View File

@@ -0,0 +1,30 @@
issue_1043: {
options = {
side_effects: true
};
input: {
function* range(start = 0, end = null, step = 1) {
if (end == null) {
end = start;
start = 0;
}
for (let i = start; i < end; i += step) {
yield i;
}
}
}
expect: {
function* range(start = 0, end = null, step = 1) {
if (null == end) {
end = start;
start = 0;
}
for (let i = start; i < end; i += step)
yield i;
}
}
}