aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/compress.js11
-rw-r--r--test/compress/properties.js19
2 files changed, 24 insertions, 6 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 6a40ef2a..8bc0e262 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -4499,12 +4499,11 @@ merge(Compressor.prototype, {
for (var i = values.length; --i >= 0;) {
if (values[i].key === self.property) {
var value = values[i].value;
- if (value instanceof AST_Function ? !value.contains_this() : !value.has_side_effects(compressor)) {
- var obj = self.expression.clone();
- obj.properties = obj.properties.slice();
- obj.properties.splice(i, 1);
- return make_sequence(self, [ obj, value ]).optimize(compressor);
- }
+ if (value instanceof AST_Function ? value.contains_this() : value.has_side_effects(compressor)) break;
+ var obj = self.expression.clone();
+ obj.properties = obj.properties.slice();
+ obj.properties.splice(i, 1);
+ return make_sequence(self, [ obj, value ]).optimize(compressor);
}
}
}
diff --git a/test/compress/properties.js b/test/compress/properties.js
index 45f870df..496a43ca 100644
--- a/test/compress/properties.js
+++ b/test/compress/properties.js
@@ -841,3 +841,22 @@ lhs_prop_2: {
"abc"[2] = "g";
}
}
+
+literal_duplicate_key_side_effects: {
+ options = {
+ unsafe: true,
+ }
+ input: {
+ console.log({
+ a: "FAIL",
+ a: console.log ? "PASS" : "FAIL"
+ }.a);
+ }
+ expect: {
+ console.log({
+ a: "FAIL",
+ a: console.log ? "PASS" : "FAIL"
+ }.a);
+ }
+ expect_stdout: "PASS"
+}