[Pkg-javascript-commits] [uglifyjs] 459/491: avoid `evaluate` of compound assignment after `dead_code` transform (#2861)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:52:04 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 aa664dea0a07656d1fa61263e3a03e7d8b5c4cc9
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Thu Feb 1 16:18:29 2018 +0800

    avoid `evaluate` of compound assignment after `dead_code` transform (#2861)
    
    fixes #2860
---
 lib/compress.js              |  1 +
 test/compress/dead-code.js   | 38 ++++++++++++++++++++++++++++++++++++++
 test/compress/reduce_vars.js | 40 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+)

diff --git a/lib/compress.js b/lib/compress.js
index 9a3446c..b4d13ec 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -5358,6 +5358,7 @@ merge(Compressor.prototype, {
                     if (in_try(level, parent instanceof AST_Throw)) break;
                     if (is_reachable(def.scope, [ def ])) break;
                     if (self.operator == "=") return self.right;
+                    def.fixed = false;
                     return make_node(AST_Binary, self, {
                         operator: self.operator.slice(0, -1),
                         left: self.left,
diff --git a/test/compress/dead-code.js b/test/compress/dead-code.js
index b66d5ac..9b45fe8 100644
--- a/test/compress/dead-code.js
+++ b/test/compress/dead-code.js
@@ -879,3 +879,41 @@ unsafe_builtin: {
         z;
     }
 }
+
+issue_2860_1: {
+    options = {
+        dead_code: true,
+        evaluate: true,
+        reduce_vars: true,
+    }
+    input: {
+        console.log(function(a) {
+            return a ^= 1;
+        }());
+    }
+    expect: {
+        console.log(function(a) {
+            return 1 ^ a;
+        }());
+    }
+    expect_stdout: "1"
+}
+
+issue_2860_2: {
+    options = {
+        dead_code: true,
+        evaluate: true,
+        inline: true,
+        passes: 2,
+        reduce_vars: true,
+    }
+    input: {
+        console.log(function(a) {
+            return a ^= 1;
+        }());
+    }
+    expect: {
+        console.log(1);
+    }
+    expect_stdout: "1"
+}
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index 2e562f9..761af9e 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -5467,3 +5467,43 @@ chained_assignments: {
     }
     expect_stdout: "5eadbeef"
 }
+
+issue_2860_1: {
+    options = {
+        dead_code: true,
+        evaluate: true,
+        reduce_vars: true,
+    }
+    input: {
+        console.log(function(a) {
+            return a ^= 1;
+            a ^= 2;
+        }());
+    }
+    expect: {
+        console.log(function(a) {
+            return 1 ^ a;
+        }());
+    }
+    expect_stdout: "1"
+}
+
+issue_2860_2: {
+    options = {
+        dead_code: true,
+        evaluate: true,
+        inline: true,
+        passes: 2,
+        reduce_vars: true,
+    }
+    input: {
+        console.log(function(a) {
+            return a ^= 1;
+            a ^= 2;
+        }());
+    }
+    expect: {
+        console.log(1);
+    }
+    expect_stdout: "1"
+}

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