fix corner case in reduce_vars (#5099)

fixes #5098
This commit is contained in:
Alex Lam S.L
2021-07-24 00:10:14 +01:00
committed by GitHub
parent 6a3fe9d1df
commit 657d525c80
2 changed files with 34 additions and 1 deletions

View File

@@ -981,7 +981,10 @@ merge(Compressor.prototype, {
if (fixed && !modified && !sym.in_arg && safe_to_assign(tw, d)) {
push_ref(d, sym);
mark(tw, d);
if (d.single_use && left instanceof AST_Destructured) d.single_use = false;
if (left instanceof AST_Destructured
|| d.orig.length == 1 && d.orig[0] instanceof AST_SymbolDefun) {
d.single_use = false;
}
tw.loop_ids[d.id] = tw.in_loop;
mark_escaped(tw, d, sym.scope, node, right, 0, 1);
sym.fixed = d.fixed = fixed;