diff --git a/lib/compress.js b/lib/compress.js index 3dcb922a..9c2dcbba 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -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){ diff --git a/test/compress/issue-1043.js b/test/compress/issue-1043.js new file mode 100644 index 00000000..78043f65 --- /dev/null +++ b/test/compress/issue-1043.js @@ -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; + } + } +}