fix corner case in inline (#5115)

fixes #5114
This commit is contained in:
Alex Lam S.L
2021-08-18 08:57:08 +01:00
committed by GitHub
parent 02eb8baa1c
commit befb99bd71
2 changed files with 69 additions and 0 deletions

View File

@@ -9980,6 +9980,7 @@ merge(Compressor.prototype, {
operator: "=", operator: "=",
left: make_node(AST_DestructuredArray, self, { left: make_node(AST_DestructuredArray, self, {
elements: fn.argnames.map(function(argname) { elements: fn.argnames.map(function(argname) {
if (argname.__unused) return make_node(AST_Hole, argname);
return argname.convert_symbol(AST_SymbolRef, process); return argname.convert_symbol(AST_SymbolRef, process);
}), }),
rest: fn.rest && fn.rest.convert_symbol(AST_SymbolRef, process), rest: fn.rest && fn.rest.convert_symbol(AST_SymbolRef, process),

View File

@@ -3057,3 +3057,71 @@ issue_5087_2: {
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=6" node_version: ">=6"
} }
issue_5114_1: {
options = {
inline: true,
unused: true,
}
input: {
var a = "PASS";
(function({}, a) {})(42);
console.log(a);
}
expect: {
var a = "PASS";
[ {} ] = [ 42 ],
void 0;
console.log(a);
}
expect_stdout: "PASS"
node_version: ">=6"
}
issue_5114_2: {
options = {
inline: true,
pure_getters: "strict",
reduce_vars: true,
side_effects: true,
unused: true,
}
input: {
var a = "PASS";
(function f([], a) {
f.length;
})([]);
console.log(a);
}
expect: {
var a = "PASS";
0;
console.log(a);
}
expect_stdout: "PASS"
node_version: ">=6"
}
issue_5114_3: {
options = {
inline: true,
pure_getters: "strict",
reduce_vars: true,
side_effects: true,
unused: true,
}
input: {
var a = "PASS";
(function f(a, {}) {
f.length;
})(null, 42);
console.log(a);
}
expect: {
var a = "PASS";
0;
console.log(a);
}
expect_stdout: "PASS"
node_version: ">=6"
}