aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/compress.js1
-rw-r--r--test/compress/objects.js26
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 3e70f2eb..fb5bcb74 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -10118,6 +10118,7 @@ merge(Compressor.prototype, {
}
if (found && !generated && typeof key == "string" && /^[0-9]+$/.test(key)) {
generated = true;
+ if (keys.has(key)) prop = keys.get(key)[0];
prop.key = make_node(AST_Number, prop, {
value: +key
});
diff --git a/test/compress/objects.js b/test/compress/objects.js
index 5e59726d..a02dd084 100644
--- a/test/compress/objects.js
+++ b/test/compress/objects.js
@@ -387,3 +387,29 @@ issue_4269_5: {
expect_stdout: "PASS"
node_version: ">=4"
}
+
+issue_4380: {
+ options = {
+ evaluate: true,
+ objects: true,
+ }
+ input: {
+ console.log({
+ get 0() {
+ return "FAIL 1";
+ },
+ 0: "FAIL 2",
+ [0]: "PASS",
+ }[0]);
+ }
+ expect: {
+ console.log({
+ get 0() {
+ return "FAIL 1";
+ },
+ [0]: ("FAIL 2", "PASS"),
+ }[0]);
+ }
+ expect_stdout: "PASS"
+ node_version: ">=4"
+}