diff options
author | kzc <kzc@users.noreply.github.com> | 2017-03-03 13:39:54 -0500 |
---|---|---|
committer | Alex Lam S.L <alexlamsl@gmail.com> | 2017-03-04 02:39:54 +0800 |
commit | ce54c9cceef68b78be7cc429988df26add904d9b (patch) | |
tree | 93b651e2b89c4ef9460f5c3e0b56e1c21b0cf37c | |
parent | 07accd2fbb78ddbdb427774b3b5287a16fa95b5f (diff) | |
download | tracifyjs-ce54c9cceef68b78be7cc429988df26add904d9b.tar.gz tracifyjs-ce54c9cceef68b78be7cc429988df26add904d9b.zip |
disallow collapse_vars constant replacement in for-in statements (#1543)
-rw-r--r-- | lib/compress.js | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/compress.js b/lib/compress.js index 2cd79128..35459006 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -525,11 +525,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); |