[Pkg-javascript-commits] [uglifyjs] 209/491: add `Date` and other known globals to `unsafe` compress option (#2302)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:51:36 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 8b890721903a0a983ffe74a3cecc6b922fa0518e
Author: kzc <kzc at users.noreply.github.com>
Date:   Wed Sep 6 14:44:26 2017 -0400

    add `Date` and other known globals to `unsafe` compress option (#2302)
---
 lib/compress.js            |  2 +-
 test/compress/dead-code.js | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/lib/compress.js b/lib/compress.js
index 6e766fb..3da7a31 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -693,7 +693,7 @@ merge(Compressor.prototype, {
         return node instanceof AST_SymbolRef && node.definition().undeclared;
     }
 
-    var global_names = makePredicate("Array Boolean console Error Function Math Number RegExp Object String");
+    var global_names = makePredicate("Array Boolean clearInterval clearTimeout console Date decodeURI decodeURIComponent encodeURI encodeURIComponent Error escape eval EvalError Function isFinite isNaN JSON Math Number parseFloat parseInt RangeError ReferenceError RegExp Object setInterval setTimeout String SyntaxError TypeError unescape URIError");
     AST_SymbolRef.DEFMETHOD("is_declared", function(compressor) {
         return !this.definition().undeclared
             || compressor.option("unsafe") && global_names(this.name);
diff --git a/test/compress/dead-code.js b/test/compress/dead-code.js
index abf5297..aea0e54 100644
--- a/test/compress/dead-code.js
+++ b/test/compress/dead-code.js
@@ -241,18 +241,54 @@ issue_2233_1: {
         Array.isArray;
         Boolean;
         console.log;
+        Date;
+        decodeURI;
+        decodeURIComponent;
+        encodeURI;
+        encodeURIComponent;
         Error.name;
+        escape;
+        eval;
+        EvalError;
         Function.length;
+        isFinite;
+        isNaN;
+        JSON;
         Math.random;
         Number.isNaN;
+        parseFloat;
+        parseInt;
         RegExp;
         Object.defineProperty;
         String.fromCharCode;
+        RangeError;
+        ReferenceError;
+        SyntaxError;
+        TypeError;
+        unescape;
+        URIError;
     }
     expect: {}
     expect_stdout: true
 }
 
+global_timeout_and_interval_symbols: {
+    options = {
+        pure_getters: "strict",
+        side_effects: true,
+        unsafe: true,
+    }
+    input: {
+        // These global symbols do not exist in the test sandbox
+        // and must be tested separately.
+        clearInterval;
+        clearTimeout;
+        setInterval;
+        setTimeout;
+    }
+    expect: {}
+}
+
 issue_2233_2: {
     options = {
         pure_getters: "strict",

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