From: Alex Lam S.L Date: Sat, 19 Dec 2020 16:14:57 +0000 (+0000) Subject: fix corner case in `objects` (#4416) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=acc2d7d8455ed7302a78948b3c8678990dc1765a;p=UglifyJS.git fix corner case in `objects` (#4416) fixes #4415 --- diff --git a/lib/compress.js b/lib/compress.js index 1aab3680..5081120c 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -10198,7 +10198,7 @@ merge(Compressor.prototype, { flush(); values.push(prop); } - if (found && !generated && typeof key == "string" && /^[0-9]+$/.test(key)) { + if (found && !generated && typeof key == "string" && /^[1-9]*[0-9]$/.test(key)) { generated = true; if (keys.has(key)) prop = keys.get(key)[0]; prop.key = make_node(AST_Number, prop, { diff --git a/test/compress/objects.js b/test/compress/objects.js index a02dd084..d35f1538 100644 --- a/test/compress/objects.js +++ b/test/compress/objects.js @@ -413,3 +413,22 @@ issue_4380: { expect_stdout: "PASS" node_version: ">=4" } + +issue_4415: { + options = { + evaluate: true, + objects: true, + } + input: { + console.log({ + ["00"]: "FAIL", + }[0] || "PASS"); + } + expect: { + console.log({ + "00": "FAIL", + }[0] || "PASS"); + } + expect_stdout: "PASS" + node_version: ">=4" +}