From 6e9dd4bf556386765c576f6f634a403271ccc6b0 Mon Sep 17 00:00:00 2001 From: kzc Date: Thu, 2 Mar 2017 19:59:49 -0500 Subject: [PATCH] disallow collapse_vars constant replacement in for-in statements --- lib/compress.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/compress.js b/lib/compress.js index 38ebbf40..aea58925 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -481,11 +481,9 @@ merge(Compressor.prototype, { // Constant single use vars can be replaced in any scope. if (var_decl.value.is_constant()) { var ctt = new TreeTransformer(function(node) { - if (node === ref) { - var parent = ctt.parent(); - if (!(parent instanceof AST_ForIn && parent.init === node)) { - return replace_var(node, parent, true); - } + if (node === ref + && !ctt.find_parent(AST_ForIn)) { + return replace_var(node, ctt.parent(), true); } }); stat.transform(ctt);