[Pkg-javascript-commits] [uglifyjs] 462/491: better fix for #2858 (#2864)

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 525a61fb559227d9ea76663f2d9b4573b4cf7475
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Thu Feb 1 20:06:36 2018 +0800

    better fix for #2858 (#2864)
---
 lib/compress.js | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/lib/compress.js b/lib/compress.js
index 1b0aa15..312ce72 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -990,7 +990,6 @@ merge(Compressor.prototype, {
                     || node instanceof AST_Debugger
                     || node instanceof AST_IterationStatement && !(node instanceof AST_For)
                     || node instanceof AST_Try
-                    || node instanceof AST_VarDef && node.value && side_effects && !references_in_scope(node.name.definition())
                     || node instanceof AST_With
                     || parent instanceof AST_For && node !== parent.init
                     || (side_effects || !replace_all)
@@ -1048,9 +1047,11 @@ merge(Compressor.prototype, {
                     || node instanceof AST_PropAccess
                         && (side_effects || node.expression.may_throw_on_access(compressor))
                     || node instanceof AST_SymbolRef
-                        && (lvalues[node.name]
-                            || side_effects && !references_in_scope(node.definition()))
-                    || (sym = lhs_or_def(node))
+                        && !(parent instanceof AST_Assign && parent.operator == "=" && parent.left === node)
+                        && (lvalues[node.name] || may_modify(node))
+                    || node instanceof AST_VarDef && node.value
+                        && (node.name.name in lvalues || may_modify(node.name))
+                    || (sym = is_lhs(node.left, node))
                         && (sym instanceof AST_PropAccess || sym.name in lvalues)
                     || may_throw
                         && (in_try ? node.has_side_effects(compressor) : side_effects_external(node))
@@ -1321,11 +1322,6 @@ merge(Compressor.prototype, {
                 return lvalues;
             }
 
-            function lhs_or_def(node) {
-                if (node instanceof AST_VarDef) return node.value && node.name;
-                return is_lhs(node.left, node);
-            }
-
             function remove_candidate(expr) {
                 if (expr.name instanceof AST_SymbolFunarg) {
                     var index = compressor.self().argnames.indexOf(expr.name);
@@ -1359,10 +1355,12 @@ merge(Compressor.prototype, {
                 return get_rvalue(expr).has_side_effects(compressor);
             }
 
-            function references_in_scope(def) {
-                if (def.orig.length == 1 && def.orig[0] instanceof AST_SymbolDefun) return true;
-                if (def.scope !== scope) return false;
-                return def.references.every(function(ref) {
+            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;
+                return !all(def.references, function(ref) {
                     return ref.scope === scope;
                 });
             }

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