[Pkg-javascript-commits] [uglifyjs] 469/491: maintain order between side-effects and externally observable assignments (#2879)
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 78a44d5ab0fd2195c8f22cc8a39193b33dad6188
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date: Sun Feb 4 03:58:49 2018 +0800
maintain order between side-effects and externally observable assignments (#2879)
fixes #2878
---
lib/compress.js | 1 -
test/compress/collapse_vars.js | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/lib/compress.js b/lib/compress.js
index 993092a..f9cd7a4 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1040,7 +1040,6 @@ merge(Compressor.prototype, {
|| node instanceof AST_PropAccess
&& (side_effects || node.expression.may_throw_on_access(compressor))
|| node instanceof AST_SymbolRef
- && !(parent instanceof AST_Assign && parent.operator == "=" && parent.left === node)
&& (lvalues[node.name] || side_effects && may_modify(node))
|| node instanceof AST_VarDef && node.value
&& (node.name.name in lvalues || side_effects && may_modify(node.name))
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index ad09edc..4191de8 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -4433,3 +4433,37 @@ issue_2873_2: {
}
expect_stdout: "0 1"
}
+
+issue_2878: {
+ options = {
+ collapse_vars: true,
+ sequences: true,
+ }
+ input: {
+ var c = 0;
+ (function (a, b) {
+ function f2() {
+ if (a) c++;
+ }
+ b = f2();
+ a = 1;
+ b && b.b;
+ f2();
+ })();
+ console.log(c);
+ }
+ expect: {
+ var c = 0;
+ (function (a, b) {
+ function f2() {
+ if (a) c++;
+ }
+ b = f2(),
+ a = 1,
+ b && b.b,
+ f2();
+ })(),
+ console.log(c);
+ }
+ 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