Skip to content

Commit

Permalink
fix: incorrect to_simple_statement (#1253)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvanjoi committed Oct 5, 2022
1 parent 34e8262 commit 3652dce
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compress/tighten-body.js
Expand Up @@ -1236,7 +1236,7 @@ export function tighten_body(statements, compressor) {
var line = block.body[i];
if (line instanceof AST_Var && declarations_only(line)) {
decls.push(line);
} else if (stat) {
} else if (stat || line instanceof AST_Const || line instanceof AST_Let) {
return false;
} else {
stat = line;
Expand Down
67 changes: 67 additions & 0 deletions test/compress/issue-1248.js
@@ -0,0 +1,67 @@
brackets_with_const: {
options = {
defaults: false,
};
input: {
if (a) {
var b;
var c;
const d = d();
const e = e();
}
}
expect: {
if(a){var b;var c;const d=d();const e=e()}
}
}

brackets_with_const_defaults: {
options = {
defaults: true,
};
input: {
if (a) {
var b;
var c;
const d = d();
const e = e();
}
}
expect: {
if(a){var b,c;const d=d(),e=e()}
}
}

brackets_with_const_let_mix_0: {
options = {
defaults: true,
};
input: {
if (a) {
var b;
var c;
const d = d();
let e = e();
}
}
expect: {
if(a){var b,c;const d=d();let e=e()}
}
}

brackets_with_const_let_mix_1: {
options = {
defaults: true,
};
input: {
if (a) {
let b = b();
var c;
var d;
const e = e();
}
}
expect: {
if(a){let b=b();var c,d;const e=e()}
}
}

0 comments on commit 3652dce

Please sign in to comment.