[Pkg-javascript-commits] [uglifyjs] 437/491: suppress `unsafe_proto` for LHS expressions (#2804)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:52:02 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 d3ce2bc9e73d9d98b34b261d282a18b9ce9d5880
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Wed Jan 17 20:41:51 2018 +0800

    suppress `unsafe_proto` for LHS expressions (#2804)
---
 lib/compress.js             |  2 +-
 test/compress/properties.js | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/lib/compress.js b/lib/compress.js
index 5fd49cf..6417822 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -5644,6 +5644,7 @@ merge(Compressor.prototype, {
         if (def) {
             return def.optimize(compressor);
         }
+        if (is_lhs(self, compressor.parent())) return self;
         if (compressor.option("unsafe_proto")
             && self.expression instanceof AST_Dot
             && self.expression.property == "prototype") {
@@ -5682,7 +5683,6 @@ merge(Compressor.prototype, {
                 break;
             }
         }
-        if (is_lhs(self, compressor.parent())) return self;
         var sub = self.flatten_object(self.property, compressor);
         if (sub) return sub.optimize(compressor);
         var ev = self.evaluate(compressor);
diff --git a/test/compress/properties.js b/test/compress/properties.js
index 933774d..af115ff 100644
--- a/test/compress/properties.js
+++ b/test/compress/properties.js
@@ -583,6 +583,25 @@ native_prototype: {
     }
 }
 
+native_prototype_lhs: {
+    options = {
+        unsafe_proto: true,
+    }
+    input: {
+        console.log(function() {
+            Function.prototype.bar = "PASS";
+            return function() {};
+        }().bar);
+    }
+    expect: {
+        console.log(function() {
+            Function.prototype.bar = "PASS";
+            return function() {};
+        }().bar);
+    }
+    expect_stdout: "PASS"
+}
+
 accessor_boolean: {
     input: {
         var a = 1;

-- 
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