aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-05-01 00:52:53 +0100
committerGitHub <noreply@github.com>2021-05-01 07:52:53 +0800
commit8bbfaacdae0b63987652766b9f3a327ff6d06231 (patch)
treee7de51df2b254703add030b1d4679efb5e33ee68
parentdf980db4a887bf6d48d872d8dd61713dc42f7842 (diff)
downloadtracifyjs-8bbfaacdae0b63987652766b9f3a327ff6d06231.tar.gz
tracifyjs-8bbfaacdae0b63987652766b9f3a327ff6d06231.zip
fix corner case in `properties` (#4889)
fixes #4888
-rw-r--r--lib/compress.js1
-rw-r--r--test/compress/properties.js17
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 0506f61c..26bcbc72 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -11533,6 +11533,7 @@ merge(Compressor.prototype, {
AST_PropAccess.DEFMETHOD("flatten_object", function(key, compressor) {
if (!compressor.option("properties")) return;
+ if (key === "__proto__") return;
var expr = this.expression;
if (expr instanceof AST_Object) {
var props = expr.properties;
diff --git a/test/compress/properties.js b/test/compress/properties.js
index 2fc2cea5..8de2dbfb 100644
--- a/test/compress/properties.js
+++ b/test/compress/properties.js
@@ -1446,3 +1446,20 @@ issue_4831_2: {
expect_stdout: "PASS"
node_version: ">=4"
}
+
+issue_4888: {
+ options = {
+ properties: true,
+ }
+ input: {
+ console.log(typeof {
+ __proto__: 42,
+ }.__proto__);
+ }
+ expect: {
+ console.log(typeof {
+ __proto__: 42,
+ }.__proto__);
+ }
+ expect_stdout: "object"
+}