Repository navigation
A switch's default clause falls through like any other clause - #538
Merged
Merged
Conversation
Without a `break`, a `default` body jumped straight out of the switch instead of into the clause after it: `default: r += "q"; case 6: r += "x"` gave "q", not "qx". mlirGenSwitchCase left the body's exit pending (to be pointed at the next clause's body) for every clause except `default`. Found by docs/bugs/testFallThrough.ts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 11, 2026
ASDAlexander77
added a commit
that referenced
this pull request
Oct 12, 2026
…558) Every repro in docs/bugs passes on main, or fails as TypeScript does: the native_ts_graphics findings were fixed by #535-#544 and #549 (the `let s = 0` one by design, with a warning since #544), testFallThrough, generic_in_generic and array_of_ifaces_cast by #538, #542 and #543, and bug14 and bug21 aren't valid TypeScript. Each fix has its regression test in tslang/test/tester, and the findings document is in the history and in those PRs, so the folder goes. Its interop notes stay, in docs/c-cpp-header-import.md: a `string` returned by a C function is its `char*`, not a copy; `number` is a `double`; and a nullable `Ref<T>` field is spelled `Ref<T> | null`. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A
defaultclause without abreaknever fell through into the clauses after it. It jumped straight out of the switch:The same happened with
defaultin the middle.docs/bugs/testFallThrough.tsreportsfail: q !== qxy.Cause
mlirGenSwitchCaseends each clause body with a branch to the merge block. If the body has nobreak, that branch is put inpendingBranchesso that the next clause points it at its own body. The condition was!hasBreak && !isDefaultCase, so adefaultbody always branched to the end of the switch.Fix
Drop
!isDefaultCase. Whendefaultis the last clause, its pending branch is never re-pointed and keeps the merge block it was created with, the same as for a lastcase.Testing
00switch_default_fallthrough.ts(compile + JIT + rc/none corpus):defaultfirst, in the middle, and last, plusdefaultwithbreak. The current release fails withassertion failed: defaultFirst(100).docs/bugs/testFallThrough.tsnow printsall OK.🤖 Generated with Claude Code