fix corner cases in rests & unused (#5063)

This commit is contained in:
Alex Lam S.L
2021-07-09 17:28:23 +01:00
committed by GitHub
parent ea7829daf5
commit 450aabaaa0
2 changed files with 88 additions and 8 deletions

View File

@@ -491,7 +491,7 @@ drop_rest_array: {
rests: true,
}
input: {
var [ ...[ a ]] = [ "PASS" ];
var [ ...[ a ] ] = [ "PASS" ];
console.log(a);
}
expect: {
@@ -542,6 +542,82 @@ drop_rest_lambda: {
node_version: ">=6"
}
keep_rest_array: {
options = {
rests: true,
}
input: {
var [ ...[ ...a ] ] = "PASS";
console.log(a.join(""));
}
expect: {
var [ ...a ] = "PASS";
console.log(a.join(""));
}
expect_stdout: "PASS"
node_version: ">=6"
}
keep_rest_arrow: {
options = {
arrows: true,
keep_fargs: false,
reduce_vars: true,
rests: true,
}
input: {
console.log(((...[ ...a ]) => a.join(""))("PASS"));
}
expect: {
console.log(((...a) => a.join(""))("PASS"));
}
expect_stdout: "PASS"
node_version: ">=6"
}
keep_rest_lambda_1: {
options = {
keep_fargs: false,
reduce_vars: true,
rests: true,
toplevel: true,
}
input: {
function f(...[ ...a ]) {
return a.join("");
}
console.log(f("PASS"), f([ 42 ]));
}
expect: {
function f(...a) {
return a.join("");
}
console.log(f("PASS"), f([ 42 ]));
}
expect_stdout: "PASS 42"
node_version: ">=6"
}
keep_rest_lambda_2: {
options = {
unused: true,
}
input: {
function f(...[ ...a ]) {
return a.join("");
}
console.log(f("PASS"), f([ 42 ]));
}
expect: {
function f(...[ ...a ]) {
return a.join("");
}
console.log(f("PASS"), f([ 42 ]));
}
expect_stdout: "PASS 42"
node_version: ">=6"
}
issue_4525_1: {
options = {
arguments: true,