typecheck: Copy classification + move tracking (RFC 0001 Phase 1)#71
Merged
proofmancer merged 1 commit intoMay 25, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lands Phase 1 of the RFC 0001 (memory model) implementation roadmap: type-system support for distinguishing `Copy` from non-`Copy` types, and move tracking that errors on use-after-move for non-`Copy` bindings.
Per the RFC, Phase 1 is the low-risk infrastructure: even if the final memory model is not full Rust-style ownership, type-level `Copy` classification and move tracking are useful and uncontroversial. Lands now; subsequent phases (grammar extensions, codegen heap, stdlib types, `extern host` ABI) can build on top.
What landed
Type-system API
New public function in `typecheck.h`:
```c
int type_is_copy(const Type *t);
```
Classification:
Move tracking
Each `ScopeEntry` gains a `moved` flag. Three new internal helpers in `typecheck.c`:
Enforcement points:
Tests
6 new typecheck tests (52 assertions total, was 34):
Existing tests
All 5 binaries still green (497 -> 503 assertions total). Existing examples (`counter-mvp.cv`, `minimal-chain.cv`) type-check unchanged: they use only Copy types and see no move-tracking diagnostics.
What this PR does NOT do
Reversibility
High. If RFC 0001 lands on per-tx arena instead of full ownership, this code stays valuable: arena-allocated types still benefit from a Copy classification and from "do not use a moved value" diagnostics. The cost of this PR is the small typecheck.c additions and the public `type_is_copy` API; reverting either is straightforward.
What unblocks next