Skip to content

[compiler] avoid empty switch case bodies #33179

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

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5fc610e
[compiler] avoid empty switch case bodies
josephsavona May 12, 2025
754bd2c
Update on "[compiler] avoid empty switch case bodies"
josephsavona May 13, 2025
310c5c6
Update on "[compiler] avoid empty switch case bodies"
josephsavona May 22, 2025
3474a7b
Update on "[compiler] avoid empty switch case bodies"
josephsavona May 23, 2025
0ef3a89
Update on "[compiler] avoid empty switch case bodies"
josephsavona May 27, 2025
8986f36
Update on "[compiler] avoid empty switch case bodies"
josephsavona May 27, 2025
eda0d6b
Update on "[compiler] avoid empty switch case bodies"
josephsavona May 28, 2025
b9c08a8
Update on "[compiler] avoid empty switch case bodies"
josephsavona May 28, 2025
2fece28
Update on "[compiler] avoid empty switch case bodies"
josephsavona May 29, 2025
4eff1ef
Update on "[compiler] avoid empty switch case bodies"
josephsavona May 29, 2025
8a68666
Update on "[compiler] avoid empty switch case bodies"
josephsavona May 30, 2025
3794d69
Update on "[compiler] avoid empty switch case bodies"
josephsavona May 30, 2025
2adcce6
Update on "[compiler] avoid empty switch case bodies"
josephsavona May 30, 2025
a868a76
Update on "[compiler] avoid empty switch case bodies"
josephsavona May 30, 2025
60b0839
Update on "[compiler] avoid empty switch case bodies"
josephsavona Jun 2, 2025
c5621f6
Update on "[compiler] avoid empty switch case bodies"
josephsavona Jun 3, 2025
7e3a373
Update on "[compiler] avoid empty switch case bodies"
josephsavona Jun 3, 2025
ec7d810
Update on "[compiler] avoid empty switch case bodies"
josephsavona Jun 3, 2025
55308cd
Update on "[compiler] avoid empty switch case bodies"
josephsavona Jun 4, 2025
b00665d
Update on "[compiler] avoid empty switch case bodies"
josephsavona Jun 5, 2025
528070a
Update on "[compiler] avoid empty switch case bodies"
josephsavona Jun 5, 2025
a0f55df
Update on "[compiler] avoid empty switch case bodies"
josephsavona Jun 5, 2025
a8a4246
Update on "[compiler] avoid empty switch case bodies"
josephsavona Jun 6, 2025
9e0e99d
Update on "[compiler] avoid empty switch case bodies"
josephsavona Jun 6, 2025
5ea1bf6
Update on "[compiler] avoid empty switch case bodies"
josephsavona Jun 6, 2025
df315dc
Update on "[compiler] avoid empty switch case bodies"
josephsavona Jun 6, 2025
bcb26b5
Update on "[compiler] avoid empty switch case bodies"
josephsavona Jun 7, 2025
1c51668
Update on "[compiler] avoid empty switch case bodies"
josephsavona Jun 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ function codegenTerminal(
? codegenPlaceToExpression(cx, case_.test)
: null;
const block = codegenBlock(cx, case_.block!);
return t.switchCase(test, [block]);
return t.switchCase(test, block.body.length === 0 ? [] : [block]);
}),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ function Component(props) {
console.log(handlers.value);
break bb0;
}
default: {
}
default:
}

t0 = handlers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ function Component(props) {
case "b": {
break bb1;
}
case "c": {
}
case "c":
default: {
x = 6;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ function Component(props) {
case 1: {
break bb0;
}
case 2: {
}
default: {
}
case 2:
default:
}
} else {
if (props.cond2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ function foo() {
case 2: {
break bb0;
}
default: {
}
default:
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,17 @@ export const FIXTURE_ENTRYPOINT = {
```javascript
function foo(x) {
bb0: switch (x) {
case 0: {
}
case 1: {
}
case 0:
case 1:
case 2: {
break bb0;
}
case 3: {
break bb0;
}
case 4: {
}
case 5: {
}
default: {
}
case 4:
case 5:
default:
}
}

Expand Down
Loading