[Pkg-javascript-commits] [uglifyjs] 127/491: fix `inline` handling of `AST_Call.args` (#2059)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:51:28 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 b9ad53d1ab166115dde78493f937782417e78e00
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Tue Jun 6 22:55:25 2017 +0800

    fix `inline` handling of `AST_Call.args` (#2059)
---
 lib/compress.js            | 14 +++++++------
 test/compress/issue-281.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 6 deletions(-)

diff --git a/lib/compress.js b/lib/compress.js
index 969acd6..e3846c3 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -3183,19 +3183,21 @@ merge(Compressor.prototype, {
                 if (body) {
                     var fn = exp.clone();
                     fn.argnames = [];
-                    fn.body = [
-                        make_node(AST_Var, self, {
+                    fn.body = [];
+                    if (exp.argnames.length > 0) {
+                        fn.body.push(make_node(AST_Var, self, {
                             definitions: exp.argnames.map(function(sym, i) {
+                                var arg = self.args[i];
                                 return make_node(AST_VarDef, sym, {
                                     name: sym,
-                                    value: self.args[i] || make_node(AST_Undefined, self)
+                                    value: arg ? arg.clone(true) : make_node(AST_Undefined, self)
                                 });
                             })
-                        })
-                    ];
+                        }));
+                    }
                     if (self.args.length > exp.argnames.length) {
                         fn.body.push(make_node(AST_SimpleStatement, self, {
-                            body: make_sequence(self, self.args.slice(exp.argnames.length))
+                            body: make_sequence(self, self.args.slice(exp.argnames.length)).clone(true)
                         }));
                     }
                     fn.body.push(make_node(AST_Return, self, {
diff --git a/test/compress/issue-281.js b/test/compress/issue-281.js
index 6b1b4b4..7a6c03b 100644
--- a/test/compress/issue-281.js
+++ b/test/compress/issue-281.js
@@ -431,3 +431,53 @@ pure_annotation: {
     }
     expect_exact: ""
 }
+
+drop_fargs: {
+    options = {
+        cascade: true,
+        inline: true,
+        keep_fargs: false,
+        side_effects: true,
+        unused: true,
+    }
+    input: {
+        var a = 1;
+        !function(a_1) {
+            a++;
+        }(a++ + (a && a.var));
+        console.log(a);
+    }
+    expect: {
+        var a = 1;
+        !function() {
+            a++;
+        }(++a && a.var);
+        console.log(a);
+    }
+    expect_stdout: "3"
+}
+
+keep_fargs: {
+    options = {
+        cascade: true,
+        inline: true,
+        keep_fargs: true,
+        side_effects: true,
+        unused: true,
+    }
+    input: {
+        var a = 1;
+        !function(a_1) {
+            a++;
+        }(a++ + (a && a.var));
+        console.log(a);
+    }
+    expect: {
+        var a = 1;
+        !function(a_1) {
+            a++;
+        }(++a && a.var);
+        console.log(a);
+    }
+    expect_stdout: "3"
+}

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