fix corner case in unused (#5847)

fixes #5843
This commit is contained in:
Alex Lam S.L
2024-06-17 04:36:02 +03:00
committed by GitHub
parent 8dc99fa25f
commit 87c9edbbc7
5 changed files with 61 additions and 6 deletions

View File

@@ -8284,6 +8284,7 @@ Compressor.prototype.compress = function(node) {
if (prop instanceof AST_Spread) return prop;
var key = prop_keys[index];
if (key instanceof AST_Node) return prop;
if (key === "__proto__") return prop;
if (drop_keys.has(key)) {
var mapped = drop_keys.get(key);
if (!mapped) return prop;
@@ -8317,7 +8318,10 @@ Compressor.prototype.compress = function(node) {
if (value.has_side_effects(compressor) && prop.value.match_symbol(function(node) {
return node instanceof AST_PropAccess;
})) break;
value = make_node(AST_Sub, node, {
value = is_identifier_string(prop.key) ? make_node(AST_Dot, node, {
expression: value,
property: prop.key,
}) : make_node(AST_Sub, node, {
expression: value,
property: make_node_from_constant(prop.key, prop),
});