fix corner case in collapse_vars (#5505)

fixes #5504
This commit is contained in:
Alex Lam S.L
2022-06-10 02:12:59 +01:00
committed by GitHub
parent 25017978e7
commit 053cb27fe3
2 changed files with 23 additions and 1 deletions

View File

@@ -2356,7 +2356,7 @@ Compressor.prototype.compress = function(node) {
if (prop.key instanceof AST_Node) prop.key = prop.key.transform(tt); if (prop.key instanceof AST_Node) prop.key = prop.key.transform(tt);
if (prop.static) { if (prop.static) {
if (prop instanceof AST_ClassField) { if (prop instanceof AST_ClassField) {
props.push(prop); if (prop.value) props.push(prop);
} else if (prop instanceof AST_ClassInit) { } else if (prop instanceof AST_ClassInit) {
props.unshift(prop); props.unshift(prop);
} }

View File

@@ -3179,3 +3179,25 @@ issue_5502: {
expect_stdout: "PASS 42" expect_stdout: "PASS 42"
node_version: ">=12" node_version: ">=12"
} }
issue_5504: {
options = {
collapse_vars: true,
}
input: {
"use strict";
var a;
console.log((a = 42, class {
static p;
}).p);
}
expect: {
"use strict";
var a;
console.log((a = 42, class {
static p;
}).p);
}
expect_stdout: "undefined"
node_version: ">=12"
}