fix corner cases in inline (#3507)

fixes #3506
This commit is contained in:
Alex Lam S.L
2019-10-22 15:41:55 +08:00
committed by GitHub
parent da5a21b240
commit 0b3705e82f
5 changed files with 167 additions and 17 deletions

View File

@@ -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
});
}
}