aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js39
1 files changed, 22 insertions, 17 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 0d19640d..43ee1126 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -6543,23 +6543,28 @@ merge(Compressor.prototype, {
}
}
} else if (self.left instanceof AST_SymbolRef) {
+ if (self.left.is_immutable()) return strip_assignment();
var def = self.left.definition();
- if (def.scope === compressor.find_parent(AST_Lambda)) {
- if (self.left.is_immutable()) return strip_assignment();
- var level = 0, node, parent = self;
- do {
- node = parent;
- parent = compressor.parent(level++);
- if (parent instanceof AST_Exit) {
- if (in_try(level, parent)) break;
- if (is_reachable(def.scope, [ def ])) break;
- def.fixed = false;
- return strip_assignment();
- }
- } while (parent instanceof AST_Binary && parent.right === node
- || parent instanceof AST_Sequence && parent.tail_node() === node
- || parent instanceof AST_UnaryPrefix);
- }
+ var local = def.scope.resolve() === compressor.find_parent(AST_Lambda);
+ var level = 0, node, parent = self;
+ do {
+ node = parent;
+ parent = compressor.parent(level++);
+ if (parent instanceof AST_Assign) {
+ if (!(parent.left instanceof AST_SymbolRef)) continue;
+ if (parent.left.definition() !== def) continue;
+ def.fixed = false;
+ return strip_assignment();
+ } else if (parent instanceof AST_Exit) {
+ if (!local) break;
+ if (in_try(level, parent)) break;
+ if (is_reachable(def.scope, [ def ])) break;
+ def.fixed = false;
+ return strip_assignment();
+ }
+ } while (parent instanceof AST_Binary && parent.right === node
+ || parent instanceof AST_Sequence && parent.tail_node() === node
+ || parent instanceof AST_UnaryPrefix);
}
}
self = self.lift_sequences(compressor);
@@ -6599,7 +6604,7 @@ merge(Compressor.prototype, {
self.right = make_node(AST_Null, right);
var may_throw = node.may_throw(compressor);
self.right = right;
- var scope = self.left.definition().scope;
+ var scope = self.left.definition().scope.resolve();
var parent;
while ((parent = compressor.parent(level++)) !== scope) {
if (parent instanceof AST_Try) {