diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-11-19 03:25:36 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-19 11:25:36 +0800 |
commit | 641406d4910a8991cbd41b0814fedd5f38958850 (patch) | |
tree | bc68e1bbc75b2aab74c3291046b5ae2961eb0934 /lib | |
parent | 134ef0b1eb5e7ec0fc02e3aa0f36e319b4b82ac4 (diff) | |
download | tracifyjs-641406d4910a8991cbd41b0814fedd5f38958850.tar.gz tracifyjs-641406d4910a8991cbd41b0814fedd5f38958850.zip |
fix corner cases in `reduce_vars` & `unused` (#4306)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js index f5dd73cc..23eb5e44 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1085,7 +1085,10 @@ merge(Compressor.prototype, { tw.loop_ids[d.id] = tw.in_loop; d.fixed = fixed; d.fixed.assigns = [ node ]; - if (name instanceof AST_SymbolConst && d.redefined()) d.single_use = false; + if (name instanceof AST_SymbolConst && d.redefined() + || !(can_drop_symbol(name) || is_safe_lexical(d))) { + d.single_use = false; + } } else { d.fixed = false; } @@ -5352,7 +5355,7 @@ merge(Compressor.prototype, { return; } var sym = def.name.definition(); - var drop_sym = !is_var || can_drop_symbol(def.name); + var drop_sym = is_var ? can_drop_symbol(def.name) : is_safe_lexical(sym); if (!drop_sym || !drop_vars || sym.id in in_use_ids) { if (def.value && indexOf_assign(sym, def) < 0) { var write_only = def.value.write_only; |