fix corner case in reduce_vars (#5435)

fixes #5434
This commit is contained in:
Alex Lam S.L
2022-05-06 02:32:47 +01:00
committed by GitHub
parent 1a4e99dc2d
commit 89a35f9fcd
2 changed files with 36 additions and 1 deletions

View File

@@ -649,7 +649,7 @@ Compressor.prototype.compress = function(node) {
}
if (!HOP(tw.safe_ids, def.id)) {
if (!safe) return false;
if (safe.read) {
if (safe.read || tw.in_loop) {
var scope = tw.find_parent(AST_BlockScope);
if (scope instanceof AST_Class) return false;
if (def.scope.resolve() !== scope.resolve()) return false;