Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect to_simple_statement #1253

Merged
merged 1 commit into from Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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()}
}
}