Skip to content

fix: prefer actual interface defs over hardcoded ast type builtins#314

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

fix: prefer actual interface defs over hardcoded ast type builtins#314
cs01 merged 1 commit intomainfrom
switch-debug

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Mar 13, 2026

Summary

  • Fixes native compiler crash when user-defined interfaces share names with built-in AST types (IfStatement, BlockStatement, etc.)
  • Root cause: getInterfaceInfo and getInterface checked hardcoded built-in types BEFORE actual interface definitions, using wrong field layouts
  • Fix: check actual interface definitions first, fall back to built-in only when no definition exists

Previously, const o: IfStatement = {...}; o.elseBlock = ... would SIGSEGV because the codegen used a hardcoded 4-field layout while the actual interface had 5 fields. This also caused GEP mismatches for BlockStatement and other AST type names.

Test plan

  • Field mutation on IfStatement-named interface no longer crashes
  • Field mutation on BlockStatement-named interface no longer crashes
  • All tests pass (npm run verify:quick)
  • Stage 1 self-hosting passes

🤖 Generated with Claude Code

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