[Pkg-javascript-commits] [uglifyjs] 242/491: fix `unsafe` expansion of object literals (#2390)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:51:40 UTC 2018


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.

commit 5fd723f14394b74f899e7b33bc9084317bf01d7d
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Sun Oct 22 15:00:36 2017 +0800

    fix `unsafe` expansion of object literals (#2390)
---
 lib/compress.js             | 11 +++++------
 test/compress/properties.js | 19 +++++++++++++++++++
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/lib/compress.js b/lib/compress.js
index 6a40ef2..8bc0e26 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 45f870d..496a43c 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"
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list