@@ -1539,7 +1539,7 @@ merge(Compressor.prototype, {
15391539 AST_Node.DEFMETHOD("match_symbol", function(predicate) {
15401540 return predicate(this);
15411541 });
1542- AST_Destructured.DEFMETHOD("match_symbol", function(predicate, ignore_side_effects) {
1542+ function match_destructured (predicate, ignore_side_effects) {
15431543 var found = false;
15441544 var tw = new TreeWalker(function(node) {
15451545 if (found) return true;
@@ -1557,7 +1557,9 @@ merge(Compressor.prototype, {
15571557 });
15581558 this.walk(tw);
15591559 return found;
1560- });
1560+ }
1561+ AST_DefaultValue.DEFMETHOD("match_symbol", match_destructured);
1562+ AST_Destructured.DEFMETHOD("match_symbol", match_destructured);
15611563
15621564 function in_async_generator(scope) {
15631565 return scope instanceof AST_AsyncGeneratorDefun || scope instanceof AST_AsyncGeneratorFunction;
@@ -7924,12 +7926,7 @@ merge(Compressor.prototype, {
79247926 var fn = exp;
79257927 if (fn instanceof AST_SymbolRef) fn = fn.fixed_value();
79267928 if (fn instanceof AST_Lambda) {
7927- fn.new = true;
7928- var assign_this_only = all(fn.body, function(stat) {
7929- return !stat.has_side_effects(compressor);
7930- });
7931- delete fn.new;
7932- if (assign_this_only) {
7929+ if (assign_this_only(fn, compressor)) {
79337930 var exprs = self.args.slice();
79347931 exprs.unshift(exp);
79357932 exprs = trim(exprs, compressor, first_in_statement, array_spread);
@@ -7941,6 +7938,16 @@ merge(Compressor.prototype, {
79417938 self.call_only = true;
79427939 return self;
79437940 });
7941+ function assign_this_only(fn, compressor) {
7942+ fn.new = true;
7943+ var result = all(fn.body, function(stat) {
7944+ return !stat.has_side_effects(compressor);
7945+ }) && all(fn.argnames, function(argname) {
7946+ return !argname.match_symbol(return_false);
7947+ }) && !(fn.rest && fn.rest.match_symbol(return_false));
7948+ delete fn.new;
7949+ return result;
7950+ }
79447951 function drop_class(self, compressor, first_in_statement) {
79457952 var exprs = [], values = [];
79467953 var props = self.properties;
0 commit comments