aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-09-29 00:01:38 +0100
committerGitHub <noreply@github.com>2020-09-29 07:01:38 +0800
commit1d835ac17de613093a538a4ab72160508197e08c (patch)
tree3ecfd2753bc60da4f484b333a2c0a5e0541e9dc0 /lib
parent9e07ac410261dcbc074a29598a974b5de7cbe1da (diff)
downloadtracifyjs-1d835ac17de613093a538a4ab72160508197e08c.tar.gz
tracifyjs-1d835ac17de613093a538a4ab72160508197e08c.zip
fix corner case in `inline` (#4160)
fixes #4159
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js18
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();