fix corner case in unused (#4757)

fixes #4756
This commit is contained in:
Alex Lam S.L
2021-03-08 23:59:52 +00:00
committed by GitHub
parent f4ee0f651c
commit 01fa430a3e
3 changed files with 50 additions and 21 deletions

View File

@@ -7323,31 +7323,28 @@ merge(Compressor.prototype, {
if (!base && !values) return null;
exprs = [];
}
if (values) {
var fn = make_node(AST_Arrow, this, {
if (base) {
var node = to_class_expr(this, true);
node.properties = [];
if (exprs.length) node.properties.push(make_node(AST_ClassMethod, this, {
key: make_sequence(this, exprs),
value: make_node(AST_Function, this, {
argnames: [],
body: [],
}).init_vars(node),
}));
exprs = [ node ];
}
if (values) exprs.push(make_node(AST_Call, this, {
expression: make_node(AST_Arrow, this, {
argnames: [],
body: [],
value: make_sequence(this, values),
});
fn.init_vars(this.parent_scope);
exprs.push(make_node(AST_Call, this, {
args: [],
expression: fn,
}));
}
exprs = exprs.length ? make_sequence(this, exprs) : null;
if (!base) return exprs;
var node = make_node(AST_ClassExpression, this, this);
node.name = null;
node.properties = [];
if (exprs) node.properties.push(make_node(AST_ClassMethod, this, {
key: exprs,
value: make_node(AST_Function, this, {
argnames: [],
body: [],
}).init_vars(node),
}).init_vars(this.parent_scope),
args: [],
}));
return node;
return make_sequence(this, exprs);
});
def(AST_Conditional, function(compressor) {
var consequent = this.consequent.drop_side_effect_free(compressor);