diff options
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/compress.js b/lib/compress.js index a3a4a63d..860eae11 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3369,9 +3369,10 @@ merge(Compressor.prototype, { var elements = []; for (var i = 0; i < this.elements.length; i++) { var element = this.elements[i]; + if (element instanceof AST_Hole) continue; var value = element._eval(compressor, ignore_side_effects, cached, depth); if (element === value) return this; - elements.push(value); + elements[i] = value; } return elements; } @@ -8446,7 +8447,8 @@ merge(Compressor.prototype, { var elements = expr.elements; var retValue = elements[index]; if (safe_to_flatten(retValue, compressor)) { - var flatten = true; + var is_hole = retValue instanceof AST_Hole; + var flatten = !is_hole; var values = []; for (var i = elements.length; --i > index;) { var value = elements[i].drop_side_effect_free(compressor); @@ -8455,12 +8457,16 @@ merge(Compressor.prototype, { if (flatten && value.has_side_effects(compressor)) flatten = false; } } - retValue = retValue instanceof AST_Hole ? make_node(AST_Undefined, retValue) : retValue; if (!flatten) values.unshift(retValue); while (--i >= 0) { var value = elements[i].drop_side_effect_free(compressor); - if (value) values.unshift(value); - else index--; + if (value) { + values.unshift(value); + } else if (is_hole) { + values.unshift(make_node(AST_Hole, elements[i])); + } else { + index--; + } } if (flatten) { values.push(retValue); |