Skip to content

Fix break in nested scope inside a switch case - #2490

Open
m910q wants to merge 1 commit into
beefytech:masterfrom
m910q:fix/nested-break-in-switch-case
Open

Fix break in nested scope inside a switch case#2490
m910q wants to merge 1 commit into
beefytech:masterfrom
m910q:fix/nested-break-in-switch-case

Conversation

@m910q

@m910q m910q commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Fix setting allHadReturns = false; when a break; appears in a nested scope.

I'm not very familiar with how the compiler works, so it's an attempt that I hope can save you some time.

AI used to identify and make a bad fix
Human used to improve fix and do some manuel testing.

Fixes #2479

This PR does not fix how break; seems to be treated differently than return; when it comes to unreachable code within a single switch case. Compile time known branches works differently for instance:
if (compTimeFalseValue) { return; } is ignored as a return, but a break; is seen as a possibility, as far as I can tell.

@bfiete

bfiete commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Can you provide some test methods that fail with the current implementation but pass with this fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nested switch break can cause EXCEPTION_ILLEGAL_INSTRUCTION

2 participants