diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-10-23 06:46:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-23 06:46:05 +0800 |
commit | 4240fba9b831c6d78fde5aac6855410bca34c30e (patch) | |
tree | c17ac09db6b332f9bad867c6cf90e67d28244339 /lib | |
parent | 267bc70d3358170794938ab915c01092c9cf59e2 (diff) | |
download | tracifyjs-4240fba9b831c6d78fde5aac6855410bca34c30e.tar.gz tracifyjs-4240fba9b831c6d78fde5aac6855410bca34c30e.zip |
fix corner cases in `unused` (#3519)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index f7fedeb2..7202219a 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3738,7 +3738,7 @@ merge(Compressor.prototype, { head.push(def); } else { var value = def.value - && (sym.references.length != 1 || !sym.replaced) + && !def.value.single_use && def.value.drop_side_effect_free(compressor); if (value) { AST_Node.warn("Side effects in initialization of unused variable {name} [{file}:{line},{col}]", template(def.name)); @@ -6158,6 +6158,7 @@ merge(Compressor.prototype, { if (single_use && fixed) { def.single_use = false; fixed._squeezed = true; + fixed.single_use = true; if (fixed instanceof AST_Defun) { fixed = make_node(AST_Function, fixed, fixed); fixed.name = make_node(AST_SymbolLambda, fixed.name, fixed.name); |