diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-10-22 15:41:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-22 15:41:55 +0800 |
commit | 0b3705e82f550b82bebb0c4f877ce8f41fc7495d (patch) | |
tree | 40c746e3814c7464de74042dae62133ea4cb8b39 /lib | |
parent | da5a21b2408ec3194728a15d2f7406c0098631f9 (diff) | |
download | tracifyjs-0b3705e82f550b82bebb0c4f877ce8f41fc7495d.tar.gz tracifyjs-0b3705e82f550b82bebb0c4f877ce8f41fc7495d.zip |
fix corner cases in `inline` (#3507)
fixes #3506
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/compress.js b/lib/compress.js index 8ef94e43..2b61e91c 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3643,8 +3643,8 @@ merge(Compressor.prototype, { if (!(sym.definition().id in in_use_ids)) { sym.__unused = true; if (trim) { + log(sym, "Dropping unused function argument {name} [{file}:{line},{col}]", template(sym)); a.pop(); - AST_Node[sym.unreferenced() ? "warn" : "info"]("Dropping unused function argument {name} [{file}:{line},{col}]", template(sym)); } } else { trim = false; @@ -3654,7 +3654,7 @@ merge(Compressor.prototype, { if (drop_funcs && node instanceof AST_Defun && node !== self) { var def = node.name.definition(); if (!(def.id in in_use_ids)) { - AST_Node[node.name.unreferenced() ? "warn" : "info"]("Dropping unused function {name} [{file}:{line},{col}]", template(node.name)); + log(node.name, "Dropping unused function {name} [{file}:{line},{col}]", template(node.name)); def.eliminated++; return make_node(AST_EmptyStatement, node); } @@ -3742,7 +3742,7 @@ merge(Compressor.prototype, { AST_Node.warn("Side effects in initialization of unused variable {name} [{file}:{line},{col}]", template(def.name)); side_effects.push(value); } else { - AST_Node[def.name.unreferenced() ? "warn" : "info"]("Dropping unused variable {name} [{file}:{line},{col}]", template(def.name)); + log(def.name, "Dropping unused variable {name} [{file}:{line},{col}]", template(def.name)); } sym.eliminated++; } @@ -3820,6 +3820,10 @@ merge(Compressor.prototype, { return node; } + function log(sym, text, props) { + AST_Node[sym.unreferenced() ? "warn" : "info"](text, props); + } + function template(sym) { return { name : sym.name, @@ -5202,7 +5206,7 @@ merge(Compressor.prototype, { if (stat instanceof AST_SimpleStatement) { return make_node(AST_UnaryPrefix, stat, { operator: "void", - expression: stat.body.clone(true) + expression: stat.body }); } } |