diff options
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/lib/compress.js b/lib/compress.js index fdf46fb9..af9ff7e3 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2546,12 +2546,7 @@ merge(Compressor.prototype, { if (parent instanceof AST_PropAccess) { var exp = parent.expression; if (exp === node) return find_stop_unused(parent, level + 1); - var sym = root_expr(exp); - if (!(sym instanceof AST_SymbolRef)) return find_stop_unused(parent, level + 1); - var lvalue = lvalues.get(sym.name); - return !lvalue || all(lvalue, function(lhs) { - return !(lhs instanceof AST_PropAccess); - }) ? find_stop_unused(parent, level + 1) : node; + return check_expr(exp); } if (parent instanceof AST_Sequence) return find_stop_unused(parent, level + 1); if (parent instanceof AST_SimpleStatement) return find_stop_unused(parent, level + 1); @@ -2562,25 +2557,28 @@ merge(Compressor.prototype, { if (parent instanceof AST_Yield) return node; return null; + function check_expr(expr) { + var replace = can_replace; + can_replace = false; + var after = stop_after; + var if_hit = stop_if_hit; + var stack = scanner.stack; + scanner.stack = [ parent ]; + expr.transform(scanner); + scanner.stack = stack; + stop_if_hit = if_hit; + stop_after = after; + can_replace = replace; + if (abort) { + abort = false; + return node; + } + return find_stop_unused(parent, level + 1); + } + function check_assignment(lhs) { if (may_throw(parent)) return node; - if (lhs !== node && lhs instanceof AST_Destructured) { - var replace = can_replace; - can_replace = false; - var after = stop_after; - var if_hit = stop_if_hit; - var stack = scanner.stack; - scanner.stack = [ parent ]; - lhs.transform(scanner); - scanner.stack = stack; - stop_if_hit = if_hit; - stop_after = after; - can_replace = replace; - if (abort) { - abort = false; - return node; - } - } + if (lhs !== node && lhs instanceof AST_Destructured) return check_expr(lhs); return find_stop_unused(parent, level + 1); } } |