Skip to content

Commit 053cb27

Browse files
authored
fix corner case in collapse_vars (#5505)
fixes #5504
1 parent 2501797 commit 053cb27

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/compress.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2356,7 +2356,7 @@ Compressor.prototype.compress = function(node) {
23562356
if (prop.key instanceof AST_Node) prop.key = prop.key.transform(tt);
23572357
if (prop.static) {
23582358
if (prop instanceof AST_ClassField) {
2359-
props.push(prop);
2359+
if (prop.value) props.push(prop);
23602360
} else if (prop instanceof AST_ClassInit) {
23612361
props.unshift(prop);
23622362
}

test/compress/classes.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3179,3 +3179,25 @@ issue_5502: {
31793179
expect_stdout: "PASS 42"
31803180
node_version: ">=12"
31813181
}
3182+
3183+
issue_5504: {
3184+
options = {
3185+
collapse_vars: true,
3186+
}
3187+
input: {
3188+
"use strict";
3189+
var a;
3190+
console.log((a = 42, class {
3191+
static p;
3192+
}).p);
3193+
}
3194+
expect: {
3195+
"use strict";
3196+
var a;
3197+
console.log((a = 42, class {
3198+
static p;
3199+
}).p);
3200+
}
3201+
expect_stdout: "undefined"
3202+
node_version: ">=12"
3203+
}

0 commit comments

Comments
 (0)