diff options
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/compress.js b/lib/compress.js index f7730cd5..5d6567f7 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -451,6 +451,7 @@ merge(Compressor.prototype, { if (tw.safe_ids[def.id]) { if (def.fixed == null) { if (is_arguments(def)) return false; + if (def.global && def.name == "arguments") return false; def.fixed = make_node(AST_Undefined, def.orig); } return true; @@ -894,9 +895,13 @@ merge(Compressor.prototype, { return orig.length == 1 && orig[0] instanceof AST_SymbolLambda; }); - function is_lhs_read_only(lhs) { + function is_lhs_read_only(lhs, compressor) { if (lhs instanceof AST_This) return true; - if (lhs instanceof AST_SymbolRef) return lhs.definition().orig[0] instanceof AST_SymbolLambda; + if (lhs instanceof AST_SymbolRef) { + var def = lhs.definition(); + return def.orig[0] instanceof AST_SymbolLambda + || compressor.exposed(def) && identifier_atom[def.name]; + } if (lhs instanceof AST_PropAccess) { lhs = lhs.expression; if (lhs instanceof AST_SymbolRef) { @@ -905,7 +910,7 @@ merge(Compressor.prototype, { } if (!lhs) return true; if (lhs.is_constant()) return true; - return is_lhs_read_only(lhs); + return is_lhs_read_only(lhs, compressor); } return false; } @@ -1220,7 +1225,7 @@ merge(Compressor.prototype, { var stop_if_hit = null; var lhs = get_lhs(candidate); var side_effects = lhs && lhs.has_side_effects(compressor); - var scan_lhs = lhs && !side_effects && !is_lhs_read_only(lhs); + var scan_lhs = lhs && !side_effects && !is_lhs_read_only(lhs, compressor); var scan_rhs = foldable(get_rhs(candidate)); if (!scan_lhs && !scan_rhs) continue; // Locate symbols which may execute code outside of scanning range |