diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-10-12 18:30:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-13 01:30:21 +0800 |
commit | 9272f662c0c89387a2bc9e7a47024ccc9d0c09a4 (patch) | |
tree | 48ea465829e6e45465df6fcf7edc6caed724c87a /lib/compress.js | |
parent | 4d33cb2f94d2a9326c67032836f8fa3d4c0731f8 (diff) | |
download | tracifyjs-9272f662c0c89387a2bc9e7a47024ccc9d0c09a4.tar.gz tracifyjs-9272f662c0c89387a2bc9e7a47024ccc9d0c09a4.zip |
fix corner case in `collapse_vars` (#4206)
fixes #4205
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js index f6de8656..bc01ebc3 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1494,14 +1494,22 @@ merge(Compressor.prototype, { } function handle_custom_scan_order(node, tt) { + if (!(node instanceof AST_BlockScope)) return; + // Skip (non-executed) functions + if (node instanceof AST_Scope) return node; + // Stop upon collision with block-scoped variables + if (node.variables && !node.variables.all(function(def) { + return !lvalues.has(def.name); + })) { + abort = true; + return node; + } // Scan object only in a for-in statement if (node instanceof AST_ForIn) { node.object = node.object.transform(tt); abort = true; return node; } - // Skip (non-executed) functions - if (node instanceof AST_Scope) return node; // Scan first case expression only in a switch statement if (node instanceof AST_Switch) { node.expression = node.expression.transform(tt); |