[Pkg-javascript-commits] [uglifyjs] 35/77: Replace the correct node when replacing in `void` sequences

Jonas Smedegaard dr at jones.dk
Tue May 19 00:02:30 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag v2.4.18
in repository uglifyjs.

commit 42ecd42ac00881f7d540cb08969ce7e2721e30d5
Author: Richard van Velzen <rvanvelzen at experty.com>
Date:   Mon Jan 12 17:09:34 2015 +0100

    Replace the correct node when replacing in `void` sequences
    
    Close #611.
---
 lib/compress.js            |  2 +-
 test/compress/issue-611.js | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/lib/compress.js b/lib/compress.js
index 1f1d4b5..72e4d92 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1937,7 +1937,7 @@ merge(Compressor.prototype, {
         if (self.cdr instanceof AST_UnaryPrefix
             && self.cdr.operator == "void"
             && !self.cdr.expression.has_side_effects(compressor)) {
-            self.cdr.operator = self.car;
+            self.cdr.expression = self.car;
             return self.cdr;
         }
         if (self.cdr instanceof AST_Undefined) {
diff --git a/test/compress/issue-611.js b/test/compress/issue-611.js
new file mode 100644
index 0000000..6f2c65d
--- /dev/null
+++ b/test/compress/issue-611.js
@@ -0,0 +1,21 @@
+issue_611: {
+  options = {
+    sequences: true,
+    side_effects: true
+  };
+  input: {
+    define(function() {
+      function fn() {}
+      if (fn()) {
+        fn();
+        return void 0;
+      }
+    });
+  }
+  expect: {
+    define(function() {
+      function fn(){}
+      if (fn()) return void fn();
+    });
+  }
+}

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