diff --git a/lib/compress.js b/lib/compress.js index 3cd632c2..e34b1d3a 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3182,22 +3182,19 @@ Compressor.prototype.compress = function(node) { var defn = last.clone(); defn.value = null; if (!value) { - node = node.clone(); - node.definitions = defns.slice(); node.definitions[index] = defn; return node; } - var body = [ - make_node(AST_SimpleStatement, value, { body: value }), - node.clone(), - ]; - body[1].definitions = defns.slice(index); - body[1].definitions[0] = defn; + var body = [ make_node(AST_SimpleStatement, value, { body: value }) ]; if (index > 0) { + var head = node.clone(); + head.definitions = defns.slice(0, index); + body.unshift(head); node = node.clone(); - node.definitions = defns.slice(0, index); - body.unshift(node); + node.definitions = defns.slice(index); } + body.push(node); + node.definitions[0] = defn; return in_list ? List.splice(body) : make_node(AST_BlockStatement, node, { body: body }); } if (!value) return in_list ? List.skip : null;