Skip to content

fix: switch default case only executes when no case matches#313

Merged
cs01 merged 1 commit intomainfrom
switch-debug
Mar 13, 2026
Merged

fix: switch default case only executes when no case matches#313
cs01 merged 1 commit intomainfrom
switch-debug

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Mar 13, 2026

Summary

  • Switch statements with default cases now work correctly — default only runs when no case matches
  • Previously default ALWAYS executed, making switch unusable (Test autodiscovery and os fix #32)
  • Unskips switch-basic.ts and switch-string.ts (skip count 18 → 16)

The fix builds an if-else-if chain bottom-up instead of independent if-statements. Uses object creation (not mutation) to avoid a native compiler codegen bug with interface field assignment.

Test plan

  • switch-basic.ts passes (both compilers)
  • switch-string.ts passes (both compilers)
  • npm run verify:quick passes (tests + Stage 1 self-hosting)
  • Stage 1 binary correctly compiles and runs switch tests

🤖 Generated with Claude Code

@cs01 cs01 merged commit 01a69be into main Mar 13, 2026
12 checks passed
@cs01 cs01 deleted the switch-debug branch March 13, 2026 02:38
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.

1 participant