diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-03-09 05:22:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-09 05:22:27 +0800 |
commit | 7e465d4a01f2cbcae24e1c60ee96969c14130287 (patch) | |
tree | 99a075b25f929cf2279e7dbcddc5e2976758cde5 /lib/compress.js | |
parent | aa80ee349d7c534a950ce6cba00c59ca0f7b5629 (diff) | |
download | tracifyjs-7e465d4a01f2cbcae24e1c60ee96969c14130287.tar.gz tracifyjs-7e465d4a01f2cbcae24e1c60ee96969c14130287.zip |
scan RHS of dropped assignments (#1581)
- similar case as #1578 but against #1450 instead
- fix `this` binding in #1450 as well
closes #1580
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/compress.js b/lib/compress.js index 302f8f56..f6b76ec2 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1901,17 +1901,15 @@ merge(Compressor.prototype, { } return node; } - if (drop_vars && assign_as_unused) { - var n = node; - while (n instanceof AST_Assign - && n.operator == "=" - && n.left instanceof AST_SymbolRef) { - var def = n.left.definition(); - if (def.id in in_use_ids - || self.variables.get(def.name) !== def) break; - n = n.right; + if (drop_vars && assign_as_unused + && node instanceof AST_Assign + && node.operator == "=" + && node.left instanceof AST_SymbolRef) { + var def = node.left.definition(); + if (!(def.id in in_use_ids) + && self.variables.get(def.name) === def) { + return maintain_this_binding(tt.parent(), node, node.right.transform(tt)); } - if (n !== node) return n; } if (node instanceof AST_For) { descend(node, this); |