aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 767d5f9c..cf46e47f 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -771,6 +771,7 @@ merge(Compressor.prototype, {
var j = fn.argnames.indexOf(arg);
return (j < 0 ? value : iife.args[j]) || make_node(AST_Undefined, iife);
};
+ d.fixed.assigns = [ arg ];
} else {
d.fixed = false;
}
@@ -4649,7 +4650,9 @@ merge(Compressor.prototype, {
return true; // don't go in nested scopes
}
if (node instanceof AST_SymbolFunarg && scope === self) {
- var_defs_by_id.add(node.definition().id, node);
+ var node_def = node.definition();
+ var_defs_by_id.add(node_def.id, node);
+ assignments.add(node_def.id, node);
}
if (node instanceof AST_Definitions && scope === self) {
node.definitions.forEach(function(def) {
@@ -4790,7 +4793,8 @@ merge(Compressor.prototype, {
var trim = compressor.drop_fargs(node, parent);
for (var a = node.argnames, i = a.length; --i >= 0;) {
var sym = a[i];
- if (!(sym.definition().id in in_use_ids)) {
+ var def = sym.definition();
+ if (!(def.id in in_use_ids)) {
sym.__unused = true;
if (trim) {
log(sym, "Dropping unused function argument {name}");
@@ -4798,6 +4802,7 @@ merge(Compressor.prototype, {
}
} else {
trim = false;
+ if (indexOf_assign(def, sym) < 0) sym.__unused = null;
}
}
fns_with_marked_args.push(node);
@@ -6457,10 +6462,10 @@ merge(Compressor.prototype, {
var side_effects = [];
for (var i = 0; i < args.length; i++) {
var trim = i >= fn.argnames.length;
- if (trim || fn.argnames[i].__unused) {
+ if (trim || "__unused" in fn.argnames[i]) {
var node = args[i].drop_side_effect_free(compressor);
- if (drop_fargs) {
- fn.argnames.splice(i, 1);
+ if (drop_fargs && (trim || fn.argnames[i].__unused)) {
+ if (!trim) fn.argnames.splice(i, 1);
args.splice(i, 1);
if (node) side_effects.push(node);
i--;