[Pkg-javascript-commits] [uglifyjs] 396/491: warn on deprecated features (#2726)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:51:56 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 7f2a591c7ecdb13a20bbad5e7c614672dd890431
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Fri Jan 5 19:36:02 2018 +0800

    warn on deprecated features (#2726)
    
    - `function.arguments`
    - `function.callers`
    
    fixes #2719
---
 lib/compress.js             |  8 ++++++++
 test/compress/issue-2719.js | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/lib/compress.js b/lib/compress.js
index 3a3aac4..e824d6f 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -5461,6 +5461,14 @@ merge(Compressor.prototype, {
     });
 
     OPT(AST_Dot, function(self, compressor){
+        if (self.property == "arguments" || self.property == "caller") {
+            compressor.warn("Function.protoype.{prop} not supported [{file}:{line},{col}]", {
+                prop: self.property,
+                file: self.start.file,
+                line: self.start.line,
+                col: self.start.col
+            });
+        }
         var def = self.resolve_defines(compressor);
         if (def) {
             return def.optimize(compressor);
diff --git a/test/compress/issue-2719.js b/test/compress/issue-2719.js
new file mode 100644
index 0000000..93e51d7
--- /dev/null
+++ b/test/compress/issue-2719.js
@@ -0,0 +1,32 @@
+warn: {
+    options = {
+        evaluate: true,
+        inline: true,
+        passes: 2,
+        properties: true,
+        reduce_funcs: true,
+        reduce_vars: true,
+        toplevel: true,
+        unused: true,
+    }
+    input: {
+        function f() {
+            return g();
+        }
+        function g() {
+            return g["call" + "er"].arguments;
+        }
+        // 3
+        console.log(f(1, 2, 3).length);
+    }
+    expect: {
+        // TypeError: Cannot read property 'arguments' of null
+        console.log(function g() {
+            return g.caller.arguments;
+        }().length);
+    }
+    expect_warnings: [
+        "WARN: Function.protoype.caller not supported [test/compress/issue-2719.js:17,19]",
+        "WARN: Function.protoype.arguments not supported [test/compress/issue-2719.js:17,19]",
+    ]
+}

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