[Pkg-javascript-commits] [uglifyjs] 465/491: fix missing corner case in #2855 (#2868)
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 b16380d66961f408932de781a3425d2992ec51b3
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date: Fri Feb 2 18:08:56 2018 +0800
fix missing corner case in #2855 (#2868)
---
lib/compress.js | 7 ++++---
test/compress/collapse_vars.js | 25 +++++++++++++++++++++++++
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/lib/compress.js b/lib/compress.js
index 312ce72..832f64f 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1044,13 +1044,15 @@ merge(Compressor.prototype, {
// but are otherwise not safe to scan into or beyond them.
var sym;
if (node instanceof AST_Call
+ || node instanceof AST_Exit
+ && (side_effects || lhs instanceof AST_PropAccess || may_modify(lhs))
|| 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] || may_modify(node))
+ && (lvalues[node.name] || side_effects && may_modify(node))
|| node instanceof AST_VarDef && node.value
- && (node.name.name in lvalues || may_modify(node.name))
+ && (node.name.name in lvalues || side_effects && may_modify(node.name))
|| (sym = is_lhs(node.left, node))
&& (sym instanceof AST_PropAccess || sym.name in lvalues)
|| may_throw
@@ -1356,7 +1358,6 @@ merge(Compressor.prototype, {
}
function may_modify(sym) {
- if (!side_effects) return false;
var def = sym.definition();
if (def.orig.length == 1 && def.orig[0] instanceof AST_SymbolDefun) return false;
if (def.scope !== scope) return true;
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index f56face..948389b 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -4191,6 +4191,31 @@ return_3: {
expect_stdout: "0"
}
+return_4: {
+ options = {
+ collapse_vars: true,
+ }
+ input: {
+ var a = "FAIL";
+ (function(b) {
+ a = "PASS";
+ return;
+ b(a);
+ })();
+ console.log(a);
+ }
+ expect: {
+ var a = "FAIL";
+ (function(b) {
+ a = "PASS";
+ return;
+ b(a);
+ })();
+ console.log(a);
+ }
+ expect_stdout: "PASS"
+}
+
issue_2858: {
options = {
collapse_vars: true,
--
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