fix corner case in unused (#5706)

fixes #5705
This commit is contained in:
Alex Lam S.L
2022-10-10 01:02:23 +01:00
committed by GitHub
parent ed7051b9bb
commit bccb1c3bd9
3 changed files with 22 additions and 7 deletions

View File

@@ -7251,15 +7251,13 @@ Compressor.prototype.compress = function(node) {
node.name = null;
}
if (node instanceof AST_Lambda) {
descend_scope();
if (drop_funcs && node !== self && node instanceof AST_LambdaDefinition) {
var def = node.name.definition();
if (!(def.id in in_use_ids)) {
log(node.name, "Dropping unused function {name}");
def.eliminated++;
if (parent instanceof AST_ExportDefault) {
descend_scope();
return to_func_expr(node, true);
}
if (parent instanceof AST_ExportDefault) return to_func_expr(node, true);
return in_list ? List.skip : make_node(AST_EmptyStatement, node);
}
}
@@ -7357,6 +7355,7 @@ Compressor.prototype.compress = function(node) {
}
fns_with_marked_args.push(node);
}
return node;
}
if (node instanceof AST_Catch && node.argname instanceof AST_Destructured) {
node.argname.transform(trimmer);