if (!exp.is_string(compressor)) return node;
return exp.drop_side_effect_free(compressor, first_in_statement);
}
+ function convert_spread(node) {
+ return node instanceof AST_Spread ? make_node(AST_Array, node, {
+ elements: [ node ]
+ }) : node;
+ }
def(AST_Node, return_this);
def(AST_Accessor, return_null);
def(AST_Array, function(compressor, first_in_statement) {
var values = trim(this.elements, compressor, first_in_statement, array_spread);
if (!values) return null;
- if (all(values, function(node) {
- return !(node instanceof AST_Spread);
- })) return make_sequence(this, values);
- if (values === this.elements) return this;
- var node = this.clone();
- node.elements = values;
- return node;
+ if (values === this.elements && all(values, function(node) {
+ return node instanceof AST_Spread;
+ })) return this;
+ return make_sequence(this, values.map(convert_spread));
});
def(AST_Assign, function(compressor) {
var left = this.left;
if (self.is_expr_pure(compressor)) {
if (self.pure) AST_Node.warn("Dropping __PURE__ call [{file}:{line},{col}]", self.start);
var args = trim(self.args, compressor, first_in_statement, array_spread);
- return args && make_sequence(self, args);
+ return args && make_sequence(self, args.map(convert_spread));
}
var exp = self.expression;
if (self.is_call_pure(compressor)) {
var exprs = self.args.slice();
exprs.unshift(exp.expression);
exprs = trim(exprs, compressor, first_in_statement, array_spread);
- return exprs && make_sequence(self, exprs);
+ return exprs && make_sequence(self, exprs.map(convert_spread));
}
var def;
if (exp instanceof AST_Function
var exprs = self.args.slice();
exprs.unshift(exp);
exprs = trim(exprs, compressor, first_in_statement, array_spread);
- return exprs && make_sequence(self, exprs);
+ return exprs && make_sequence(self, exprs.map(convert_spread));
}
if (!fn.contains_this()) return make_node(AST_Call, self, self);
}