fix corner case in collapse_vars (#5639)

fixes #5638
This commit is contained in:
Alex Lam S.L
2022-08-31 01:44:04 +01:00
committed by GitHub
parent d530f9332c
commit f63b7b079d
3 changed files with 115 additions and 3 deletions

View File

@@ -3416,9 +3416,15 @@ Compressor.prototype.compress = function(node) {
if (def.references.length - def.replaced == referenced) return true;
if (!def.fixed) return false;
if (!lhs.fixed) return false;
if (def.references.filter(function(ref) {
return ref.fixed === lhs.fixed;
}).length != referenced) return false;
var matched = 0;
if (!all(def.references, function(ref, index) {
var fixed = ref.fixed;
if (!fixed) return false;
if (fixed.to_binary || fixed.to_prefix) return false;
if (fixed === lhs.fixed) matched++;
return true;
})) return false;
if (matched != referenced) return false;
verify_ref = true;
return true;
}