Skip to content

Commit

Permalink
fix corner case in dead_code (#4983)
Browse files Browse the repository at this point in the history
fixes #4982
  • Loading branch information
alexlamsl committed May 30, 2021
1 parent 8d23496 commit b9d5bba
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -3646,6 +3646,8 @@ merge(Compressor.prototype, {
var block;
stat.walk(new TreeWalker(function(node, descend) {
if (node instanceof AST_DefClass) {
node.extends = null;
node.properties = [];
push(node);
return true;
}
Expand Down
46 changes: 46 additions & 0 deletions test/compress/classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1679,3 +1679,49 @@ issue_4962_2: {
expect_stdout: "undefined"
node_version: ">=12"
}

issue_4982_1: {
options = {
dead_code: true,
}
input: {
"use strict";
try {} catch (e) {
class A extends 42 {}
}
console.log("PASS");
}
expect: {
"use strict";
{
class A {}
}
console.log("PASS");
}
expect_stdout: "PASS"
node_version: ">=4"
}

issue_4982_2: {
options = {
dead_code: true,
}
input: {
var a = "PASS";
try {} catch (e) {
class A {
static p = a = "FAIL";
}
}
console.log(a);
}
expect: {
var a = "PASS";
{
class A {}
}
console.log(a);
}
expect_stdout: "PASS"
node_version: ">=12"
}

0 comments on commit b9d5bba

Please sign in to comment.