fix corner case in loops (#4275)

fixes #4274
This commit is contained in:
Alex Lam S.L
2020-11-13 18:08:05 +00:00
committed by GitHub
parent fba27bfb71
commit 6fd5b5b371
3 changed files with 109 additions and 1 deletions

View File

@@ -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");