Repository navigation
Description
Summary
The compiler silently corrupts type resolution when a single .w source file exceeds approximately 14,000 lines of code. The symptom is unresolved type for field '' in struct 'StructName' errors with empty field names, or unresolved type for field 'field_name' in struct 'StructName' for fields that are clearly valid.
Reproduction
Adding ~200 lines of new function bodies to src/Codegen.w (currently ~14K lines) triggers the error. The same code compiles fine when split across multiple builds using a two-phase bootstrap approach (stubs first, then real implementations after seed update).
Key observations:
- Adding 350 lines of comments (no code) does NOT trigger the error — 14,125 lines with comments builds fine
- Adding ~200 lines of code (new function bodies with local variables, function calls, etc.) DOES trigger it
- The error is deterministic, not intermittent
- The error manifests differently on repeated builds but always involves type resolution
- Sometimes appears as
unresolved type for field '' in struct 'ContextError'(empty field name) - Sometimes appears as
unresolved type for field 'mir_input' in struct 'Codegen'
Root Cause Hypothesis
The issue is likely an internal pool or table overflow in the compiler's type resolution phase. When the total number of AST nodes, symbols, or type entries exceeds a fixed-size buffer or triggers a reallocation that invalidates existing pointers, type resolution silently produces garbage results instead of failing cleanly.
Impact
This is currently worked around by:
- Removing dead code to stay under the limit
- Two-phase bootstrap (add stubs, update seed, fill in implementations)
But src/Codegen.w is already at 14,013 lines and growing. The AST codegen removal (Phase 4 in docs/deprecate_ast.md) will help by deleting ~3,000-5,000 lines, but the limit will eventually be hit again as the compiler evolves.
Suggested Fix
Either:
- Find and fix the overflow: Add bounds checking / dynamic resizing to whichever internal table is overflowing. The
type_extraVec or the sema type tables are likely candidates. - Support multi-file compilation units: Allow splitting large files like
Codegen.winto multiple files that share the same struct scope. - Add a clear error: At minimum, detect the overflow condition and emit a clear diagnostic instead of silently corrupting type data.
Environment
- Platform: macOS ARM64 (Darwin 25.3.0)
- Self-hosting compiler, fixpoint-verified
- LLVM 22 statically linked
Activity
Stack overflow test + expect-stderr directive
Stack overflow test + expect-stderr directive
test: cover one-liner edge cases — multi-fragment -n/-p, !~, source-file
build: a bundle store slot is keyed by the compiler sources that buil…
with -n/-p: the code is spliced verbatim into a brace-bodied loop; a …
MirLower: a call through a let-alias of a non-Copy fn field calls the…
MirLower: a call through a let-alias of a non-Copy fn field calls the…
Sema refuses Vec.range with anything but one range argument: v.range(…
Sema refuses Vec.range with anything but one range argument: v.range(…
Runtime/Windows/fs: remove_tree trailing-slash link (#1951); VecRange…
Build graph: one producer per output, checked at graph load (#2014); …
D86 (#1864): assert/require/check are compiler-known forms; the messa…
Link: the macOS deployment target covers the archives a program links…
proposal: bridge the implementation gap (the #1 goal, Eric 2026-11-02) (