aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 919ee20f..aff5c643 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -525,6 +525,14 @@ merge(Compressor.prototype, {
return lhs instanceof AST_SymbolRef && lhs.definition().orig[0] instanceof AST_SymbolLambda;
}
+ function is_reference_const(ref) {
+ if (!(ref instanceof AST_SymbolRef)) return false;
+ var orig = ref.definition().orig;
+ for (var i = orig.length; --i >= 0;) {
+ if (orig[i] instanceof AST_SymbolConst) return true;
+ }
+ }
+
function find_variable(compressor, name) {
var scope, i = 0;
while (scope = compressor.parent(i++)) {
@@ -790,7 +798,8 @@ merge(Compressor.prototype, {
return make_node(AST_SymbolRef, expr.name, expr.name);
}
} else {
- return expr[expr instanceof AST_Assign ? "left" : "expression"];
+ var lhs = expr[expr instanceof AST_Assign ? "left" : "expression"];
+ return !is_reference_const(lhs) && lhs;
}
}
@@ -1973,6 +1982,7 @@ merge(Compressor.prototype, {
&& node instanceof AST_Assign
&& node.operator == "="
&& node.left instanceof AST_SymbolRef
+ && !is_reference_const(node.left)
&& scope === self) {
node.right.walk(tw);
return true;
@@ -3178,7 +3188,7 @@ merge(Compressor.prototype, {
&& (left.operator == "++" || left.operator == "--")) {
left = left.expression;
} else left = null;
- if (!left || is_lhs_read_only(left)) {
+ if (!left || is_lhs_read_only(left) || is_reference_const(left)) {
expressions[++i] = cdr;
continue;
}