diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-11-17 05:24:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-17 05:24:02 +0800 |
commit | 10c1a78772c1d6ca1bc7f78f0fa1f2ab50b07ae2 (patch) | |
tree | bd5934e68527c31d35926c754b1173174dcb40eb /lib/compress.js | |
parent | a6a0319f1c758013e8f1be9632fa30b031144835 (diff) | |
download | tracifyjs-10c1a78772c1d6ca1bc7f78f0fa1f2ab50b07ae2.tar.gz tracifyjs-10c1a78772c1d6ca1bc7f78f0fa1f2ab50b07ae2.zip |
fix corner case in `collapse_vars` (#3591)
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/compress.js b/lib/compress.js index e85cf5d3..801cbaea 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1691,13 +1691,17 @@ merge(Compressor.prototype, { if (expr instanceof AST_Unary) return false; if (side_effects) return false; if (value_def) return true; - if (lhs instanceof AST_SymbolRef) { - var def = lhs.definition(); - if (def.references.length - def.replaced == (candidate instanceof AST_VarDef ? 1 : 2)) { - return true; - } + if (!(lhs instanceof AST_SymbolRef)) return false; + var referenced; + if (expr instanceof AST_VarDef) { + referenced = 1; + } else if (expr.operator == "=") { + referenced = 2; + } else { + return false; } - return false; + var def = lhs.definition(); + return def.references.length - def.replaced == referenced; } function symbol_in_lvalues(sym, parent) { |