fix corner case in side_effects (#5490)

fixes #5489
This commit is contained in:
Alex Lam S.L
2022-06-06 13:32:32 +01:00
committed by GitHub
parent 88b4283200
commit 00665766da
2 changed files with 74 additions and 6 deletions

View File

@@ -8638,17 +8638,26 @@ Compressor.prototype.compress = function(node) {
if (base || self.name || !compressor.has_directive("use strict")) {
var node = to_class_expr(self);
if (!base) node.extends = null;
node.properties = values ? values.length == init ? values : [ make_node(AST_ClassField, self, {
static: true,
key: exprs.length ? make_sequence(self, exprs) : "c",
value: make_value(),
}) ] : exprs.length ? [ make_node(AST_ClassMethod, self, {
node.properties = [];
if (values) {
if (values.length == init) {
if (exprs.length) values.unshift(make_node(AST_ClassField, self, {
key: make_sequence(self, exprs),
value: null,
}));
node.properties = values;
} else node.properties.push(make_node(AST_ClassField, self, {
static: true,
key: exprs.length ? make_sequence(self, exprs) : "c",
value: make_value(),
}));
} else if (exprs.length) node.properties.push(make_node(AST_ClassMethod, self, {
key: make_sequence(self, exprs),
value: make_node(AST_Function, self, {
argnames: [],
body: [],
}).init_vars(node),
}) ] : [];
}));
return node;
}
if (values) exprs.push(make_node(AST_Call, self, {