diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/compress.js b/lib/compress.js index 360bbe7a..69394a3d 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -4793,15 +4793,15 @@ merge(Compressor.prototype, { for (var a = node.argnames, i = a.length; --i >= 0;) { var sym = a[i]; var def = sym.definition(); - if (!(def.id in in_use_ids)) { + if (def.id in in_use_ids) { + trim = false; + if (indexOf_assign(def, sym) < 0) sym.__unused = null; + } else { sym.__unused = true; if (trim) { log(sym, "Dropping unused function argument {name}"); a.pop(); } - } else { - trim = false; - if (indexOf_assign(def, sym) < 0) sym.__unused = null; } } fns_with_marked_args.push(node); @@ -7047,9 +7047,10 @@ merge(Compressor.prototype, { value: null })); } + if (!value) return; var sym = make_node(AST_SymbolRef, name, name); def.references.push(sym); - if (value) expressions.push(make_node(AST_Assign, self, { + expressions.push(make_node(AST_Assign, self, { operator: "=", left: sym, right: value @@ -7070,7 +7071,12 @@ merge(Compressor.prototype, { var symbol = make_node(AST_SymbolVar, name, name); name.definition().orig.push(symbol); if (!value && in_loop) value = make_node(AST_Undefined, self); - append_var(decls, expressions, symbol, value); + if ("__unused" in name) { + append_var(decls, expressions, symbol); + if (value) expressions.push(value); + } else { + append_var(decls, expressions, symbol, value); + } } } decls.reverse(); |