fix corner case in hoist_props & unused (#5455)

fixes #5454
This commit is contained in:
Alex Lam S.L
2022-05-18 21:45:38 +01:00
committed by GitHub
parent 63f16e4616
commit 33c9c48318
2 changed files with 30 additions and 0 deletions

View File

@@ -7240,6 +7240,7 @@ Compressor.prototype.compress = function(node) {
});
var index = indexOf_assign(sym, def);
if (index >= 0) assign_in_use[sym.id][index] = assign;
sym.assignments++;
sym.eliminated++;
return assign;
}));

View File

@@ -3567,3 +3567,32 @@ issue_5423: {
expect_stdout: "function"
node_version: ">=6"
}
issue_5454: {
options = {
hoist_props: true,
reduce_vars: true,
side_effects: true,
toplevel: true,
unused: true,
}
input: {
function f(a) {
var a = 42, a = {
p: [ a ] = [],
};
return "PASS";
}
console.log(f());
}
expect: {
console.log(function(a) {
a = 42, a = {
p: [ a ] = [],
};
return "PASS";
}());
}
expect_stdout: "PASS"
node_version: ">=6"
}