From: Alex Lam S.L Date: Wed, 10 Feb 2021 15:06:12 +0000 (+0000) Subject: enhance `collapse_vars` (#4637) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=f5659f292b796539a0960887f601b3f08c856bb7;p=UglifyJS.git enhance `collapse_vars` (#4637) --- diff --git a/lib/compress.js b/lib/compress.js index 94719afa..8b5b020d 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2170,6 +2170,8 @@ merge(Compressor.prototype, { } } if (expr.value) extract_candidates(expr.value); + } else if (expr instanceof AST_Yield) { + if (expr.expression) extract_candidates(expr.expression); } hit_stack.pop(); } @@ -2197,6 +2199,7 @@ merge(Compressor.prototype, { if (parent instanceof AST_Switch) return node; if (parent instanceof AST_Unary) return node; if (parent instanceof AST_VarDef) return node; + if (parent instanceof AST_Yield) return node; return null; } @@ -2307,6 +2310,7 @@ merge(Compressor.prototype, { if (parent instanceof AST_Switch) return find_stop_unused(parent, level + 1); if (parent instanceof AST_Unary) return find_stop_unused(parent, level + 1); if (parent instanceof AST_VarDef) return check_assignment(parent.name); + if (parent instanceof AST_Yield) return node; return null; function check_assignment(lhs) {