Problem
CLAUDE.md lists ~15 "patterns that crash native code" as prose rules. Every contributor must memorize them. Two have been converted to enforced sema passes (or-fallback-checker, type-assertion-checker), but the rest are honor-system.
Rules to enforce
High priority (proven crash classes)
- alloca for collection structs in class fields — detect
alloca %Set, %Map, etc. stored into class fields. Should use GC_malloc. Sema pass or codegen-time check.
- ObjectArray element access loses type info —
arr[i] returns i8*; accessing fields without as NamedType reads garbage. Could warn when fields are accessed on untyped ObjectArray elements.
- Inline `as { ... }` on opaque source — type-assertion-checker handles named-to-named casts, but `object as { field: string }` bypasses it. Sema pass pending.
Medium priority
- Arrow functions can't capture `this` — detect arrow functions that reference `this` and emit error
- Map<object, V> unsupported — detect Map instantiation with non-primitive key types
- Interface method dispatch broken — warn when calling methods on interface-typed fields (as opposed to class-typed)
Lower priority (rare triggers)
- Bulk class method additions — detect classes exceeding ~25 methods and warn
- Missing returns false positive — improve exhaustive switch detection in checkMissingReturns
Approach
Each rule = one sema pass file in src/semantic/, one error fixture in tests/fixtures/errors/. Ship incrementally, one per PR.
Success criteria
Every prose rule in CLAUDE.md "Patterns That Crash" either has an enforced sema pass or is marked as not-yet-reproducible.
Problem
CLAUDE.md lists ~15 "patterns that crash native code" as prose rules. Every contributor must memorize them. Two have been converted to enforced sema passes (or-fallback-checker, type-assertion-checker), but the rest are honor-system.
Rules to enforce
High priority (proven crash classes)
alloca %Set,%Map, etc. stored into class fields. Should use GC_malloc. Sema pass or codegen-time check.arr[i]returnsi8*; accessing fields withoutas NamedTypereads garbage. Could warn when fields are accessed on untyped ObjectArray elements.Medium priority
Lower priority (rare triggers)
Approach
Each rule = one sema pass file in
src/semantic/, one error fixture intests/fixtures/errors/. Ship incrementally, one per PR.Success criteria
Every prose rule in CLAUDE.md "Patterns That Crash" either has an enforced sema pass or is marked as not-yet-reproducible.