fix corner case in `spread` (#4364)
authorAlex Lam S.L <alexlamsl@gmail.com>
Fri, 11 Dec 2020 18:19:11 +0000 (18:19 +0000)
committerGitHub <noreply@github.com>
Fri, 11 Dec 2020 18:19:11 +0000 (02:19 +0800)
fixes #4363

lib/compress.js
test/compress/spread.js

index 1862fd1..27b080b 100644 (file)
@@ -10051,7 +10051,9 @@ merge(Compressor.prototype, {
             found = true;
             var exp = prop.expression;
             if (compressor.option("spread") && exp instanceof AST_Object && all(exp.properties, function(prop) {
-                return !(prop instanceof AST_ObjectGetter || prop instanceof AST_Spread);
+                return !(prop instanceof AST_ObjectGetter
+                    || prop instanceof AST_ObjectSetter && prop.key instanceof AST_Node
+                    || prop instanceof AST_Spread);
             })) {
                 changed = true;
                 exp.properties.forEach(function(prop) {
index 8af7bff..7834875 100644 (file)
@@ -758,3 +758,26 @@ issue_4361: {
     ]
     node_version: ">=8"
 }
+
+issue_4363: {
+    options = {
+        objects: true,
+        spread: true,
+    }
+    input: {
+        ({
+            ...{
+                set [console.log("PASS")](v) {},
+            },
+        });
+    }
+    expect: {
+        ({
+            ...{
+                set [console.log("PASS")](v) {},
+            },
+        });
+    }
+    expect_stdout: "PASS"
+    node_version: ">=8"
+}