fix corner case in arguments (#4398)

fixes #4397
This commit is contained in:
Alex Lam S.L
2020-12-18 01:42:07 +00:00
committed by GitHub
parent c1256c399a
commit 82d2aa4acf
3 changed files with 34 additions and 9 deletions

View File

@@ -1048,7 +1048,7 @@ merge(Compressor.prototype, {
});
def(AST_Unary, function(tw, descend) {
var node = this;
if (!unary_arithmetic[node.operator]) return;
if (!UNARY_POSTFIX[node.operator]) return;
var exp = node.expression;
if (!(exp instanceof AST_SymbolRef)) {
mark_assignment_to_arguments(exp);
@@ -1978,7 +1978,7 @@ merge(Compressor.prototype, {
extract_candidates(expr.expression);
expr.body.forEach(extract_candidates);
} else if (expr instanceof AST_Unary) {
if (unary_arithmetic[expr.operator]) {
if (UNARY_POSTFIX[expr.operator]) {
candidates.push(hit_stack.slice());
} else {
extract_candidates(expr.expression);
@@ -3473,8 +3473,6 @@ merge(Compressor.prototype, {
});
var lazy_op = makePredicate("&& ||");
var unary_arithmetic = makePredicate("++ --");
var unary_side_effects = makePredicate("delete ++ --");
function is_lhs(node, parent) {
if (parent instanceof AST_Assign) return parent.left === node && node;
@@ -3725,7 +3723,7 @@ merge(Compressor.prototype, {
});
var scan_modified = new TreeWalker(function(node) {
if (node instanceof AST_Assign) modified(node.left);
if (node instanceof AST_Unary && unary_arithmetic[node.operator]) modified(node.expression);
if (node instanceof AST_Unary && UNARY_POSTFIX[node.operator]) modified(node.expression);
});
function modified(node) {
if (node instanceof AST_PropAccess) {
@@ -4964,7 +4962,7 @@ merge(Compressor.prototype, {
return true;
}
if (node instanceof AST_Unary) {
if (!unary_arithmetic[node.operator]) return;
if (!UNARY_POSTFIX[node.operator]) return;
var sym = node.expression;
if (!(sym instanceof AST_SymbolRef)) return;
mark(sym, true, true);
@@ -9885,7 +9883,7 @@ merge(Compressor.prototype, {
&& is_arguments(def = expr.definition())
&& prop instanceof AST_Number
&& (fn = def.scope) === find_lambda()
&& !(assigned && fn.uses_arguments === "d")) {
&& fn.uses_arguments < (assigned ? 2 : 3)) {
var index = prop.value;
if (parent instanceof AST_UnaryPrefix && parent.operator == "delete") {
if (!def.deleted) def.deleted = [];