2.7 KiB
2.7 KiB
PR-21 — Distinguish peek, borrow, and mutate in Core IR
Goal
Restore the semantic distinction mandated by PBS.
Required Semantics
| Operation | Effect |
|---|---|
peek |
Copy storage → stack value |
borrow |
Temporary read-only view |
mutate |
Temporary mutable view + commit |
Required Changes
- Lower PBS
peek→BeginPeek/EndPeek - Lower PBS
borrow→BeginBorrow/EndBorrow - Lower PBS
mutate→BeginMutate/EndMutate
These must not share the same lowering path.
Tests
- PBS snippet with all three operations
- Assert distinct Core IR instruction sequences
PR-22 — Make Allocation Shape Explicit in Core IR
Goal
Stop implicit / guessed heap layouts.
Required Changes
- Replace any shape-less
Allocwith:
Alloc { ty: TypeId, slots: u32 }
Rules:
TypeIdcomes from frontend type checkingslotsis derived deterministically (struct fields / array size)
Tests
- Allocating storage struct emits correct
slots - Allocating array emits correct
slots
PR-23 — Eliminate Invalid Call Fallbacks
Goal
Prevent invalid bytecode generation.
Required Changes
-
Remove all fallbacks to
FunctionId(0)or equivalent -
On unresolved symbols during lowering:
- Emit canonical diagnostic (
E_RESOLVE_UNDEFINEDorE_LOWER_UNSUPPORTED) - Abort lowering
- Emit canonical diagnostic (
Tests
- PBS program calling missing function → compile error
- No Core IR or VM IR emitted
PR-24 — Validate Contract Calls in Frontend (Arity + Types)
Goal
Move contract validation to compile time.
Required Changes
-
During PBS type checking:
- Validate argument count against contract signature
- Validate argument types
-
Lower only validated calls to
HostCall
Tests
- Wrong arity →
E_TYPE_MISMATCH - Correct call lowers to Core IR
HostCall
PR-25 — Core IR Invariants Test Suite
Goal
Lock in correct semantics before touching the VM.
Required Invariants
- Every
Begin*has a matchingEnd* - Gate passed to
Begin*is available atEnd* - No storage writes without
BeginMutate - No silent fallbacks
Tests
- Property-style tests or golden IR assertions
STOP POINT
After PR-25:
- Core IR correctly represents PBS HIP semantics
- Lowering is deterministic and safe
- VM is still unchanged
Only after this point may VM PRs begin.
Any VM work before this is a hard rejection.
Instruction to Junie
If any rule in this document is unclear:
- Stop
- Add a failing test
- Document the ambiguity
Do not invent behavior.
This document is binding.