Skip to content

Commit

Permalink
fix corner case in inline (#5736)
Browse files Browse the repository at this point in the history
fixes #5735
  • Loading branch information
alexlamsl committed Nov 14, 2022
1 parent 7f424a5 commit 1d400f1
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -10948,6 +10948,7 @@ Compressor.prototype.compress = function(node) {
in_order = null;
return;
}
if (node instanceof AST_Class) return abort = true;
if (node instanceof AST_Scope) return abort = true;
if (avoid && node instanceof AST_Symbol && avoid[node.name]) return abort = true;
if (node instanceof AST_SymbolRef) {
Expand Down
47 changes: 47 additions & 0 deletions test/compress/classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3927,3 +3927,50 @@ issue_5724: {
expect_stdout: ReferenceError("a is not defined")
node_version: ">=12"
}

issue_5735_1: {
options = {
inline: true,
}
input: {
console.log(typeof function(a) {
return class {
static P = { ...a };
};
}([ 42..p ] = []));
}
expect: {
console.log(typeof function(a) {
return class {
static P = { ...a };
};
}([ 42..p ] = []));
}
expect_stdout: "function"
node_version: ">=12"
}

issue_5735_2: {
options = {
inline: true,
}
input: {
console.log(typeof function(a) {
return class {
p = a;
};
}(console.log("PASS")));
}
expect: {
console.log(typeof function(a) {
return class {
p = a;
};
}(console.log("PASS")));
}
expect_stdout: [
"PASS",
"function",
]
node_version: ">=12"
}

0 comments on commit 1d400f1

Please sign in to comment.