fix corner cases with parameter scope (#5567)

fixes #5566
This commit is contained in:
Alex Lam S.L
2022-07-17 09:03:12 +01:00
committed by GitHub
parent 685ab357cc
commit ec4558be29
3 changed files with 193 additions and 35 deletions

View File

@@ -241,23 +241,6 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
CHANGED = true;
return node.name;
}
else if (node instanceof U.AST_DestructuredArray) {
var expr = node.elements[0];
if (expr && !(expr instanceof U.AST_Hole)) {
node.start._permute++;
CHANGED = true;
return expr;
}
}
else if (node instanceof U.AST_DestructuredObject) {
// first property's value
var expr = node.properties[0];
if (expr) {
node.start._permute++;
CHANGED = true;
return expr.value;
}
}
else if (node instanceof U.AST_Defun) {
switch (((node.start._permute += step) * steps | 0) % 2) {
case 0:
@@ -275,6 +258,23 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
}
}
}
else if (node instanceof U.AST_DestructuredArray) {
var expr = node.elements[0];
if (expr && !(expr instanceof U.AST_Hole)) {
node.start._permute++;
CHANGED = true;
return expr;
}
}
else if (node instanceof U.AST_DestructuredObject) {
// first property's value
var expr = node.properties[0];
if (expr) {
node.start._permute++;
CHANGED = true;
return expr.value;
}
}
else if (node instanceof U.AST_DWLoop) {
var expr = [
node.condition,
@@ -296,6 +296,16 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
return to_statement(expr);
}
}
else if (node instanceof U.AST_ExportDeclaration) {
node.start._permute++;
CHANGED = true;
return node.body;
}
else if (node instanceof U.AST_ExportDefault) {
node.start._permute++;
CHANGED = true;
return to_statement(node.body);
}
else if (node instanceof U.AST_Finally) {
// drop finally block
node.start._permute++;
@@ -351,6 +361,15 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
return to_statement(expr);
}
}
else if (node instanceof U.AST_LabeledStatement) {
if (node.body instanceof U.AST_Statement
&& !has_loopcontrol(node.body, node.body, node)) {
// replace labelled statement with its non-labelled body
node.start._permute = REPLACEMENTS.length;
CHANGED = true;
return node.body;
}
}
else if (node instanceof U.AST_Object) {
// first property's value
var expr = node.properties[0];
@@ -441,15 +460,6 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
return to_statement(node.definitions[0].value);
}
}
else if (node instanceof U.AST_LabeledStatement) {
if (node.body instanceof U.AST_Statement
&& !has_loopcontrol(node.body, node.body, node)) {
// replace labelled statement with its non-labelled body
node.start._permute = REPLACEMENTS.length;
CHANGED = true;
return node.body;
}
}
if (in_list) {
// drop switch branches