diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-09-25 01:04:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-25 08:04:51 +0800 |
commit | af35cd32f28dfc3f79380d8f1b8294fc550d07e2 (patch) | |
tree | ca1811b7c045e0b3f600f363ab3c012eab6b481b /lib | |
parent | 7de8daa4b151fc47080d5a5f6329c3f80b9a5e7d (diff) | |
download | tracifyjs-af35cd32f28dfc3f79380d8f1b8294fc550d07e2.tar.gz tracifyjs-af35cd32f28dfc3f79380d8f1b8294fc550d07e2.zip |
fix corner case in `merge_vars` (#4151)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/compress.js b/lib/compress.js index 883345b6..517f29fd 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -4331,7 +4331,7 @@ merge(Compressor.prototype, { AST_Scope.DEFMETHOD("merge_variables", function(compressor) { if (!compressor.option("merge_vars")) return; - var self = this, segment = {}; + var self = this, segment = {}, root; var first = [], last = [], index = 0; var declarations = new Dictionary(); var references = Object.create(null); @@ -4414,10 +4414,8 @@ merge(Compressor.prototype, { if (node instanceof AST_Scope) { push(); segment.block = node; - if (node instanceof AST_Lambda && node.name) { - if (node !== self) segment.loop = true; - references[node.name.definition().id] = false; - } + if (node === self) root = segment; + if (node instanceof AST_Lambda && node.name) references[node.name.definition().id] = false; descend(); pop(); return true; @@ -4563,7 +4561,8 @@ merge(Compressor.prototype, { definition: def, }); } - refs.start = self; + if (segment.block !== self) return references[def.id] = false; + refs.start = root; } prev[def.id] = last.length; last.push({ |