aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 578e73cc..83d20e8f 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -9390,7 +9390,8 @@ merge(Compressor.prototype, {
|| self.right.left.is_number(compressor))
&& (self.operator != "-" || !self.left.is_negative_zero())
&& (self.right.left.is_constant_expression()
- || !self.right.right.has_side_effects(compressor))) {
+ || !self.right.right.has_side_effects(compressor))
+ && !is_modify_array(self.right.right)) {
self = make_node(AST_Binary, self, {
operator: align(self.operator, self.right.operator),
left: make_node(AST_Binary, self.left, {
@@ -9534,6 +9535,21 @@ merge(Compressor.prototype, {
}
return try_evaluate(compressor, self);
+ function is_modify_array(node) {
+ var found = false;
+ node.walk(new TreeWalker(function(node) {
+ if (found) return true;
+ if (node instanceof AST_Assign) {
+ if (node.left instanceof AST_PropAccess) return found = true;
+ } else if (node instanceof AST_Unary) {
+ if (unary_side_effects[node.operator] && node.expression instanceof AST_PropAccess) {
+ return found = true;
+ }
+ }
+ }));
+ return found;
+ }
+
function align(ref, op) {
switch (ref) {
case "-":