@@ -6948,7 +6948,7 @@ Compressor.prototype.compress = function(node) {
6948
6948
node.properties = properties;
6949
6949
return node;
6950
6950
}
6951
- if (node instanceof AST_SymbolDeclaration) return node.definition().id in in_use_ids ? node : null ;
6951
+ if (node instanceof AST_SymbolDeclaration) return trim_decl( node) ;
6952
6952
});
6953
6953
var tt = new TreeTransformer(function(node, descend, in_list) {
6954
6954
var parent = tt.parent();
@@ -7063,9 +7063,7 @@ Compressor.prototype.compress = function(node) {
7063
7063
} else {
7064
7064
var trimmed = trim_destructured(rest, make_node(AST_Array, parent, {
7065
7065
elements: args.slice(argnames.length),
7066
- }), function(node) {
7067
- return node.definition().id in in_use_ids ? node : null;
7068
- }, !node.uses_arguments, rest);
7066
+ }), trim_decl, !node.uses_arguments, rest);
7069
7067
rest = trimmed.name;
7070
7068
args.length = argnames.length;
7071
7069
if (trimmed.value.elements.length) [].push.apply(args, trimmed.value.elements);
@@ -7095,6 +7093,8 @@ Compressor.prototype.compress = function(node) {
7095
7093
} else if (trim) {
7096
7094
log(sym, "Dropping unused function argument {name}");
7097
7095
argnames.pop();
7096
+ def.eliminated++;
7097
+ sym.unused = true;
7098
7098
} else {
7099
7099
sym.unused = true;
7100
7100
}
@@ -7104,9 +7104,7 @@ Compressor.prototype.compress = function(node) {
7104
7104
if (!args || spread < i) {
7105
7105
funarg = sym.transform(trimmer);
7106
7106
} else {
7107
- var trimmed = trim_destructured(sym, args[i], function(node) {
7108
- return node.definition().id in in_use_ids ? node : null;
7109
- }, trim_value, sym);
7107
+ var trimmed = trim_destructured(sym, args[i], trim_decl, trim_value, sym);
7110
7108
funarg = trimmed.name;
7111
7109
if (trimmed.value) args[i] = trimmed.value;
7112
7110
}
@@ -7706,6 +7704,12 @@ Compressor.prototype.compress = function(node) {
7706
7704
return (node instanceof AST_DefaultValue ? node.name : node) instanceof AST_SymbolDeclaration;
7707
7705
}
7708
7706
7707
+ function trim_decl(node) {
7708
+ if (node.definition().id in in_use_ids) return node;
7709
+ if (node instanceof AST_SymbolFunarg) node.unused = true;
7710
+ return null;
7711
+ }
7712
+
7709
7713
function trim_default(trimmer, node) {
7710
7714
node.value = node.value.transform(tt);
7711
7715
var name = node.name.transform(trimmer);
@@ -13660,7 +13664,7 @@ Compressor.prototype.compress = function(node) {
13660
13664
if (def.orig.length == 1 && fn.functions.has(name)) return;
13661
13665
if (!all(def.orig, function(sym) {
13662
13666
if (sym instanceof AST_SymbolConst) return false;
13663
- if (sym instanceof AST_SymbolFunarg) return def.scope.resolve() !== fn;
13667
+ if (sym instanceof AST_SymbolFunarg) return !sym.unused && def.scope.resolve() !== fn;
13664
13668
if (sym instanceof AST_SymbolLet) return false;
13665
13669
return true;
13666
13670
})) return;
0 commit comments