fix corner case in hoist_props (#5223)

fixes #5222
This commit is contained in:
Alex Lam S.L
2021-12-15 18:57:34 +00:00
committed by GitHub
parent 509896a410
commit 9e927ecc9a
3 changed files with 41 additions and 0 deletions

View File

@@ -1537,6 +1537,12 @@ var AST_Assign = DEFNODE("Assign", null, {
throw new Error("left must be assignable: " + node.TYPE);
}
});
} else if (!(this.left instanceof AST_Infinity
|| this.left instanceof AST_NaN
|| this.left instanceof AST_PropAccess && !this.left.optional
|| this.left instanceof AST_SymbolRef
|| this.left instanceof AST_Undefined)) {
throw new Error("left must be assignable");
}
},
}, AST_Binary);

View File

@@ -7795,6 +7795,7 @@ Compressor.prototype.compress = function(node) {
var defs = defs_by_id[node.definition().id];
if (!defs) return;
if (node.fixed_value() !== defs.value) return;
if (is_lhs(node, this.parent())) return;
return make_node(AST_Object, node, { properties: [] });
}
}));