[Pkg-javascript-commits] [uglifyjs] 129/491: fix `cascade` on multi-branch evaluations (#2067)
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 9db0695b10799349c005fc14ab1268c2478c25fd
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date: Wed Jun 7 19:52:01 2017 +0800
fix `cascade` on multi-branch evaluations (#2067)
Partially reverts #2059 as this has better coverage and performance.
fixes #2062
---
lib/compress.js | 8 ++++----
test/compress/sequences.js | 20 ++++++++++++++++++++
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/lib/compress.js b/lib/compress.js
index e3846c3..81b9cca 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -3187,17 +3187,16 @@ merge(Compressor.prototype, {
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: arg ? arg.clone(true) : make_node(AST_Undefined, self)
+ value: self.args[i] || 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)).clone(true)
+ body: make_sequence(self, self.args.slice(exp.argnames.length))
}));
}
fn.body.push(make_node(AST_Return, self, {
@@ -3316,6 +3315,7 @@ merge(Compressor.prototype, {
continue;
}
var parent = null, field;
+ expressions[j] = cdr = cdr.clone();
while (true) {
if (cdr.equivalent_to(left)) {
var car = expressions[i];
@@ -3352,7 +3352,7 @@ merge(Compressor.prototype, {
break;
}
parent = cdr;
- cdr = cdr[field];
+ cdr = cdr[field] = cdr[field].clone();
}
}
end = i;
diff --git a/test/compress/sequences.js b/test/compress/sequences.js
index 1049256..f41b603 100644
--- a/test/compress/sequences.js
+++ b/test/compress/sequences.js
@@ -710,3 +710,23 @@ issue_27: {
})(jQuery);
}
}
+
+issue_2062: {
+ options = {
+ booleans: true,
+ cascade: true,
+ conditionals: true,
+ side_effects: true,
+ }
+ input: {
+ var a = 1;
+ if ([ a || a++ + a--, a++ + a--, a && a.var ]);
+ console.log(a);
+ }
+ expect: {
+ var a = 1;
+ a || (a++, a--), a++, --a && a.var;
+ console.log(a);
+ }
+ 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