Skip to content

Introduce a checked-program boundary across the compiler - #70

Open
izaak wants to merge 2 commits into
audulus:mainfrom
izaak:refactor/checked-program-pr
Open

Introduce a checked-program boundary across the compiler#70
izaak wants to merge 2 commits into
audulus:mainfrom
izaak:refactor/checked-program-pr

Conversation

@izaak

@izaak izaak commented Sep 9, 2026

Copy link
Copy Markdown

Compiler passes previously reconstructed binding and callee identity from source names and signatures, maintained shadowing bookkeeping, and repeated capture discovery. This change records bindings, solved types, and source locations in CheckedProgram bodies, then supplies explicit concrete function/global instances after specialization. Recorded identities and shared capture discovery replace those duplicated lookup and bookkeeping paths.

Existing syntax and overload/coercion policies remain intact. The safety changes reject previously missed violations of existing requirements.

  • Migrate specialization, safety checking, field hoisting, copy elision, Cranelift, LLVM, register VM, and Stack lowering to checked bodies and recorded identities. Share capture discovery and borrowed-call classification. Replace synthetic assumption-function wrappers with body-level operations.
  • Add structural validation at template and concrete program boundaries. Retain checked templates across entry-point changes and specialization retries, while parse/type failures and stale validation options block execution.
  • Check every retained concrete function body before hoisting, including ordinary callers of generics. Given bounded(x: i32, value: T) require x >= 0 {}, the call bounded(-1, true) is now rejected after specialization.
  • Keep partial editor facts in a separate SourceAnalysis snapshot so hover and navigation can recover around source errors without publishing an executable program.
  • Add docs/CHECKED_PROGRAM.md, and revise the specialization documentation.

Validated on macOS ARM64 with LLVM 18: default and LLVM workspace builds/tests, backend golden suites, AOT integration tests, and a library check without default features all passed.

Regression coverage includes binding and capture identity, specialization safety and lifecycle, editor recovery, DSP buffer rebinding and persistent state, and cancellation with successful reentry.

Record lexical bindings, solved types, and source locations in owned checked
bodies. Specialization produces explicit concrete function/global instances
consumed by safety, hoisting, copy elision, Cranelift, LLVM, register VM, and
Stack lowering.

Replace repeated name lookup, shadowing bookkeeping, and separate capture
walkers with recorded identities and shared capture discovery.

Retain templates across entry-point changes and specialization retries,
validate publication boundaries, and keep partial editor facts separate from
executable programs. Check concrete requirements in every retained function
body before code motion.

Preserve existing syntax and overload/coercion policies. Share borrowed-call
classification and add ownership, lifecycle, safety, editor recovery, DSP state,
and cancellation regressions. Document the contract in docs/CHECKED_PROGRAM.md.

Validated on macOS ARM64 with LLVM 18: default and LLVM workspace
builds/tests, backend golden suites, AOT integration tests, and a library
check without default features all passed.
The Ubuntu LLVM job builds without the Clang-only C Stack interpreter.
Three unguarded references to stack_interp_bridge prevented its library
tests from compiling.

Gate the C Stack portions of the hoisting and VM codegen regressions with
has_stack_interp while keeping register VM coverage active on every build.

Validation: reproduced all three original errors with has_stack_interp
disabled locally; all 439 LLVM library tests now pass in that configuration.
All 13 affected hoisting and VM codegen tests also pass with the C Stack
interpreter enabled. git diff --check passes.
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