[Pkg-javascript-commits] [uglifyjs] 448/491: fix `unsafe` `evaluate` of `AST_Array` (#2825)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:52:03 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 e2dc9cf091684638a75035e7acddbc32ac5c0785
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Sun Jan 21 01:39:44 2018 +0800

    fix `unsafe` `evaluate` of `AST_Array` (#2825)
    
    fixes #2822
---
 lib/compress.js           |  5 ++++-
 test/compress/evaluate.js | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/lib/compress.js b/lib/compress.js
index 49185ae..2803b85 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -2240,7 +2240,10 @@ merge(Compressor.prototype, {
                 var elements = [];
                 for (var i = 0, len = this.elements.length; i < len; i++) {
                     var element = this.elements[i];
-                    if (element instanceof AST_Function) continue;
+                    if (element instanceof AST_Function) {
+                        elements.push(element);
+                        continue;
+                    }
                     var value = element._eval(compressor, depth);
                     if (element === value) return this;
                     elements.push(value);
diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js
index d40880f..0d26982 100644
--- a/test/compress/evaluate.js
+++ b/test/compress/evaluate.js
@@ -1360,3 +1360,17 @@ issue_2535_3: {
         "WARN: Condition left of || always true [test/compress/evaluate.js:1341,20]",
     ]
 }
+
+issue_2822: {
+    options = {
+        evaluate: true,
+        unsafe: true,
+    }
+    input: {
+        console.log([ function() {}, "PASS", "FAIL" ][1]);
+    }
+    expect: {
+        console.log("PASS");
+    }
+    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