fix corner case in collapse_vars (#4866)

fixes #4865
This commit is contained in:
Alex Lam S.L
2021-04-24 13:04:31 +01:00
committed by GitHub
parent 10dd9d4eaf
commit c296a63fb3
2 changed files with 21 additions and 3 deletions

View File

@@ -2560,7 +2560,7 @@ merge(Compressor.prototype, {
if (def.undeclared) return;
if (is_arguments(def)) return;
if (value !== rhs) {
if (value.is_immutable()) return;
if (is_lhs_read_only(value, compressor)) return;
var referenced = def.references.length - def.replaced;
if (referenced < 2) return;
candidate = candidate.clone();
@@ -7330,8 +7330,9 @@ merge(Compressor.prototype, {
def(AST_Assign, function(compressor) {
var left = this.left;
if (left instanceof AST_PropAccess) {
if (left.expression.may_throw_on_access(compressor, true)) return this;
if (compressor.has_directive("use strict") && left.expression.is_constant()) return this;
var expr = left.expression;
if (expr.may_throw_on_access(compressor, true)) return this;
if (compressor.has_directive("use strict") && expr.is_constant()) return this;
}
if (left.has_side_effects(compressor)) return this;
var right = this.right;