Skip to content

Commit

Permalink
fix corner case in collapse_vars (#5505)
Browse files Browse the repository at this point in the history
fixes #5504
  • Loading branch information
alexlamsl committed Jun 10, 2022
1 parent 2501797 commit 053cb27
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compress.js
Expand Up @@ -2356,7 +2356,7 @@ Compressor.prototype.compress = function(node) {
if (prop.key instanceof AST_Node) prop.key = prop.key.transform(tt);
if (prop.static) {
if (prop instanceof AST_ClassField) {
props.push(prop);
if (prop.value) props.push(prop);
} else if (prop instanceof AST_ClassInit) {
props.unshift(prop);
}
Expand Down
22 changes: 22 additions & 0 deletions test/compress/classes.js
Expand Up @@ -3179,3 +3179,25 @@ issue_5502: {
expect_stdout: "PASS 42"
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"
}

0 comments on commit 053cb27

Please sign in to comment.