@@ -7323,31 +7323,28 @@ merge(Compressor.prototype, {
|
|||||||
if (!base && !values) return null;
|
if (!base && !values) return null;
|
||||||
exprs = [];
|
exprs = [];
|
||||||
}
|
}
|
||||||
if (values) {
|
if (base) {
|
||||||
var fn = make_node(AST_Arrow, this, {
|
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: [],
|
argnames: [],
|
||||||
body: [],
|
body: [],
|
||||||
value: make_sequence(this, values),
|
value: make_sequence(this, values),
|
||||||
});
|
}).init_vars(this.parent_scope),
|
||||||
fn.init_vars(this.parent_scope);
|
args: [],
|
||||||
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),
|
|
||||||
}));
|
}));
|
||||||
return node;
|
return make_sequence(this, exprs);
|
||||||
});
|
});
|
||||||
def(AST_Conditional, function(compressor) {
|
def(AST_Conditional, function(compressor) {
|
||||||
var consequent = this.consequent.drop_side_effect_free(compressor);
|
var consequent = this.consequent.drop_side_effect_free(compressor);
|
||||||
|
|||||||
@@ -438,6 +438,7 @@ AST_Scope.DEFMETHOD("init_vars", function(parent_scope) {
|
|||||||
});
|
});
|
||||||
AST_Arrow.DEFMETHOD("init_vars", function(parent_scope) {
|
AST_Arrow.DEFMETHOD("init_vars", function(parent_scope) {
|
||||||
init_scope_vars(this, parent_scope);
|
init_scope_vars(this, parent_scope);
|
||||||
|
return this;
|
||||||
});
|
});
|
||||||
AST_AsyncArrow.DEFMETHOD("init_vars", function(parent_scope) {
|
AST_AsyncArrow.DEFMETHOD("init_vars", function(parent_scope) {
|
||||||
init_scope_vars(this, parent_scope);
|
init_scope_vars(this, parent_scope);
|
||||||
|
|||||||
@@ -1244,3 +1244,34 @@ new_target: {
|
|||||||
expect_stdout: "function"
|
expect_stdout: "function"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4756: {
|
||||||
|
options = {
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
try {
|
||||||
|
class A extends 42 {
|
||||||
|
static [console.log("foo")] = console.log("bar");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log("baz");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
try {
|
||||||
|
(class extends 42 {
|
||||||
|
[console.log("foo")]() {}
|
||||||
|
}),
|
||||||
|
(() => console.log("bar"))();
|
||||||
|
} catch (e) {
|
||||||
|
console.log("baz");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"baz",
|
||||||
|
]
|
||||||
|
node_version: ">=12"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user