aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-12-11 18:19:11 +0000
committerGitHub <noreply@github.com>2020-12-12 02:19:11 +0800
commit1020d3725612b7e1225765e698138570172c841a (patch)
tree5baf6e0e2e8e68852f3267ba22a199b4bbf56b3c
parent076739db079306c103b8a6c45dde2371b25c64e4 (diff)
downloadtracifyjs-1020d3725612b7e1225765e698138570172c841a.tar.gz
tracifyjs-1020d3725612b7e1225765e698138570172c841a.zip
fix corner case in `spread` (#4364)
fixes #4363
-rw-r--r--lib/compress.js4
-rw-r--r--test/compress/spread.js23
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 1862fd10..27b080bb 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -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) {
diff --git a/test/compress/spread.js b/test/compress/spread.js
index 8af7bffb..78348758 100644
--- a/test/compress/spread.js
+++ b/test/compress/spread.js
@@ -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"
+}