fix corner case in hoist_props (#5654)

fixes #5653
This commit is contained in:
Alex Lam S.L
2022-09-08 03:55:59 +01:00
committed by GitHub
parent 5b5f6e329c
commit 02d966d914
2 changed files with 37 additions and 3 deletions

View File

@@ -8486,9 +8486,18 @@ Compressor.prototype.compress = function(node) {
return make_sequence(node, assignments);
}
if (node instanceof AST_Scope) {
if (node === self) return;
var parent = tt.parent();
if (parent.TYPE == "Call" && parent.expression === node) return;
var parent;
if (node === self || (parent = tt.parent()).TYPE == "Call" && parent.expression === node) {
if (!(is_arrow(node) && node.value)) return;
var stat = node.first_statement();
node.body = [ stat ];
node.value = null;
descend(node, tt);
if (node.body.length == 1 && node.body[0] === stat) {
node.body.length = 0;
node.value = stat.value;
}
}
return node;
}
if (node instanceof AST_VarDef) {