[Pkg-javascript-commits] [uglifyjs] 466/491: fix assignment logic in `reduce_vars` (#2872)
Jonas Smedegaard
dr at jones.dk
Wed Feb 14 19:52:05 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 e773f0392769794173358b362a645facb51b2ad2
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date: Sat Feb 3 01:33:09 2018 +0800
fix assignment logic in `reduce_vars` (#2872)
fixes #2869
---
lib/compress.js | 12 ++++++------
test/compress/reduce_vars.js | 26 ++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/lib/compress.js b/lib/compress.js
index 832f64f..77636cb 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -710,19 +710,19 @@ merge(Compressor.prototype, {
def(AST_VarDef, function(tw, descend) {
var node = this;
var d = node.name.definition();
- if (safe_to_assign(tw, d, node.value)) {
- if (node.value) {
+ if (node.value) {
+ if (safe_to_assign(tw, d, node.value)) {
d.fixed = function() {
return node.value;
};
tw.loop_ids[d.id] = tw.in_loop;
mark(tw, d, false);
descend();
+ mark(tw, d, true);
+ return true;
+ } else {
+ d.fixed = false;
}
- mark(tw, d, true);
- return true;
- } else if (node.value) {
- d.fixed = false;
}
});
def(AST_While, function(tw) {
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index 761af9e..c014820 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -5507,3 +5507,29 @@ issue_2860_2: {
}
expect_stdout: "1"
}
+
+issue_2869: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ }
+ input: {
+ var c = "FAIL";
+ (function f(a) {
+ var a;
+ if (!f) a = 0;
+ if (a) c = "PASS";
+ })(1);
+ console.log(c);
+ }
+ expect: {
+ var c = "FAIL";
+ (function f(a) {
+ var a;
+ if (!f) a = 0;
+ if (a) c = "PASS";
+ })(1);
+ console.log(c);
+ }
+ expect_stdout: "PASS"
+}
--
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