aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-11-13 18:08:05 +0000
committerGitHub <noreply@github.com>2020-11-14 02:08:05 +0800
commit6fd5b5b371dd805e679042916c7c0fae79798d75 (patch)
treec12e4c47ed2a26bcb8589b93657307fb25db20e3 /lib
parentfba27bfb71cd973f76e8d1007edec935f25ace77 (diff)
downloadtracifyjs-6fd5b5b371dd805e679042916c7c0fae79798d75.tar.gz
tracifyjs-6fd5b5b371dd805e679042916c7c0fae79798d75.zip
fix corner case in `loops` (#4275)
fixes #4274
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index f44552aa..97252f7f 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1166,7 +1166,9 @@ merge(Compressor.prototype, {
function as_statement_array(thing) {
if (thing === null) return [];
- if (thing instanceof AST_BlockStatement) return thing.body;
+ if (thing instanceof AST_BlockStatement) return all(thing.body, function(stat) {
+ return !(stat instanceof AST_Const || stat instanceof AST_Let);
+ }) ? thing.body : [ thing ];
if (thing instanceof AST_EmptyStatement) return [];
if (thing instanceof AST_Statement) return [ thing ];
throw new Error("Can't convert thing to statement array");