fix corner case in unused (#3987)

fixes #3986
This commit is contained in:
Alex Lam S.L
2020-06-10 19:01:23 +01:00
committed by GitHub
parent ed69adedcd
commit 596fad182e
2 changed files with 41 additions and 3 deletions

View File

@@ -4674,9 +4674,13 @@ merge(Compressor.prototype, {
var rhs = assign.right;
if (!assign.write_only) return rhs;
if (!(rhs instanceof AST_Binary && lazy_op[rhs.operator])) return rhs;
var sym = assign.left;
if (!(sym instanceof AST_SymbolRef) || sym.name != rhs.left.name) return rhs;
return rhs.right.has_side_effects(compressor) ? rhs : rhs.right;
if (!(rhs.left instanceof AST_SymbolRef)) return rhs;
if (!(assign.left instanceof AST_SymbolRef)) return rhs;
var def = assign.left.definition();
if (rhs.left.definition() !== def) return rhs;
if (rhs.right.has_side_effects(compressor)) return rhs;
if (track_assigns(def, rhs.left)) add_assigns(def, rhs.left);
return rhs.right;
}
function scan_ref_scoped(node, descend, init) {