fix corner cases with rest parameters (#4526)

fixes #4525
This commit is contained in:
Alex Lam S.L
2021-01-09 00:38:51 +00:00
committed by GitHub
parent 553034fe52
commit 770f3ba5fe
2 changed files with 44 additions and 2 deletions

View File

@@ -5669,8 +5669,9 @@ merge(Compressor.prototype, {
}
if (node.rest) {
node.rest = node.rest.transform(trimmer);
if (node.rest instanceof AST_DestructuredArray && node.rest.elements.length == 0
|| node.rest instanceof AST_DestructuredObject && node.rest.properties.length == 0) {
if (!(node.uses_arguments && !tt.has_directive("use strict"))
&& (node.rest instanceof AST_DestructuredArray && node.rest.elements.length == 0
|| node.rest instanceof AST_DestructuredObject && node.rest.properties.length == 0)) {
node.rest = null;
}
}
@@ -10467,6 +10468,7 @@ merge(Compressor.prototype, {
argname = null;
} else if (compressor.has_directive("use strict")
|| fn.name
|| fn.rest
|| !(fn_parent instanceof AST_Call && index < fn_parent.args.length)
|| !all(fn.argnames, function(argname) {
return argname instanceof AST_SymbolFunarg;