AST_Node.DEFMETHOD("match_symbol", function(predicate) {
return predicate(this);
});
- AST_Destructured.DEFMETHOD("match_symbol", function(predicate, ignore_side_effects) {
+ function match_destructured(predicate, ignore_side_effects) {
var found = false;
var tw = new TreeWalker(function(node) {
if (found) return true;
});
this.walk(tw);
return found;
- });
+ }
+ AST_DefaultValue.DEFMETHOD("match_symbol", match_destructured);
+ AST_Destructured.DEFMETHOD("match_symbol", match_destructured);
function in_async_generator(scope) {
return scope instanceof AST_AsyncGeneratorDefun || scope instanceof AST_AsyncGeneratorFunction;
var fn = exp;
if (fn instanceof AST_SymbolRef) fn = fn.fixed_value();
if (fn instanceof AST_Lambda) {
- fn.new = true;
- var assign_this_only = all(fn.body, function(stat) {
- return !stat.has_side_effects(compressor);
- });
- delete fn.new;
- if (assign_this_only) {
+ if (assign_this_only(fn, compressor)) {
var exprs = self.args.slice();
exprs.unshift(exp);
exprs = trim(exprs, compressor, first_in_statement, array_spread);
self.call_only = true;
return self;
});
+ function assign_this_only(fn, compressor) {
+ fn.new = true;
+ var result = all(fn.body, function(stat) {
+ return !stat.has_side_effects(compressor);
+ }) && all(fn.argnames, function(argname) {
+ return !argname.match_symbol(return_false);
+ }) && !(fn.rest && fn.rest.match_symbol(return_false));
+ delete fn.new;
+ return result;
+ }
function drop_class(self, compressor, first_in_statement) {
var exprs = [], values = [];
var props = self.properties;