diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-07-21 01:06:42 +0100 |
---|---|---|
committer | alexlamsl <alexlamsl@gmail.com> | 2020-07-21 17:21:58 +0800 |
commit | bce3919748b1ece4d98625fee450f6096d7bb849 (patch) | |
tree | 6de9a73119f1cc959ec6e24eb342258bad760659 /lib/compress.js | |
parent | 61b66e83f1885dd8ad18ff510e38ab601ebf4c5c (diff) | |
download | tracifyjs-bce3919748b1ece4d98625fee450f6096d7bb849.tar.gz tracifyjs-bce3919748b1ece4d98625fee450f6096d7bb849.zip |
fix corner case in `unused` (#4018)
fixes #4017
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js index a464b664..8ea5d8c9 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -4456,8 +4456,13 @@ merge(Compressor.prototype, { var sym = def.name.definition(); if (!drop_vars || sym.id in in_use_ids) { if (def.value && indexOf_assign(sym, def) < 0) { - def.value = def.value.drop_side_effect_free(compressor); - if (def.value) def.value.tail_node().write_only = false; + var value = def.value.drop_side_effect_free(compressor); + if (def.value !== value) def.value = value && make_sequence(def.value, [ + value, + make_node(AST_Number, def.value, { + value: 0 + }), + ]); } var old_def, var_defs = var_defs_by_id.get(sym.id); if (!def.value) { |