fix corner case in unused (#5101)

fixes #5100
This commit is contained in:
Alex Lam S.L
2021-07-26 09:44:34 +01:00
committed by GitHub
parent 657d525c80
commit 9b82f9be91
2 changed files with 71 additions and 6 deletions

View File

@@ -1003,3 +1003,69 @@ issue_5089_2: {
expect_stdout: "undefined"
node_version: ">=8"
}
issue_5100_1: {
options = {
passes: 2,
pure_getters: "strict",
side_effects: true,
unused: true,
}
input: {
var a;
[ {
p: {},
...a
} ] = [ {
p: {
q: a,
} = 42,
r: "PASS",
} ];
console.log(a.r);
}
expect: {
var a;
[ {
p: {},
...a
} ] = [ {
p: [ a = 42["q"] ],
r: "PASS",
} ];
console.log(a.r);
}
expect_stdout: "PASS"
node_version: ">=8"
}
issue_5100_2: {
options = {
passes: 2,
pure_getters: "strict",
side_effects: true,
unused: true,
}
input: {
var a;
[ {
p: {},
...a
} ] = [ {
p: (console.log("PASS"), {
q: a,
} = 42),
} ];
}
expect: {
var a;
[ {
p: {},
...a
} ] = [ {
p: [ console.log("PASS"), a = 42["q"] ],
} ];
}
expect_stdout: "PASS"
node_version: ">=10"
}