diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/lib/compress.js b/lib/compress.js index e4426fa3..fe2e6242 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1972,15 +1972,9 @@ merge(Compressor.prototype, { function find_stop_value(node, level) { var parent = scanner.parent(level); if (parent instanceof AST_Array) return find_stop_value(parent, level + 1); - if (parent instanceof AST_Assign) { - if (may_throw(parent)) return node; - if (parent.left instanceof AST_SymbolRef) { - var name = parent.left.name; - if (lhs.name == name) return node; - if (value_def.name == name) return node; - } - return find_stop_value(parent, level + 1); - } + if (parent instanceof AST_Assign) return may_throw(parent) || parent.left.match_symbol(function(ref) { + return ref instanceof AST_SymbolRef && (lhs.name == ref.name || value_def.name == ref.name); + }) ? node : find_stop_value(parent, level + 1); if (parent instanceof AST_Binary) { if (lazy_op[parent.operator] && parent.left !== node) { do { @@ -2034,12 +2028,9 @@ merge(Compressor.prototype, { if (parent.operator == "delete") return node; return find_stop_value(parent, level + 1); } - if (parent instanceof AST_VarDef) { - var name = parent.name.name; - if (lhs.name == name) return node; - if (value_def.name == name) return node; - return find_stop_value(parent, level + 1); - } + if (parent instanceof AST_VarDef) return parent.name.match_symbol(function(sym) { + return sym instanceof AST_SymbolDeclaration && (lhs.name == sym.name || value_def.name == sym.name); + }) ? node : find_stop_value(parent, level + 1); if (parent instanceof AST_While) { if (parent.condition !== node) return node; return find_stop_value(parent, level + 1); |