docs: define contract AIR bindings and access diagnostics
This commit is contained in:
1 parent
5ed0d86e36
commit
2db752dba9
9 files changed
+479
-6
No files matched your search
@@ -99,6 +99,12 @@ For a contracted ret, retain the body state before return transfer. Run the ordi
|
||||
|
||||
Otherwise check every installed post in prefix order against the original pre-transfer body state, using isolated temporary view/state bookkeeping for each. Isolation includes borrow/loan state, transfer summaries and emitted verifier events; commit ordinary return facts/events only once, and discard synthetic temporary-view events after each virtual check. A failed clause cannot leave synthetic live borrows or suppress a later clause or the ordinary leak records. Type/P rules ensure these helpers cannot permanently mutate caller state, so successful sequential predicates have the same available roots. This is static legality collection, not runtime execution of later predicates after a trap. Runtime still stops at the first failing predicate. Finally merge ordinary and virtual facts using the existing AIR (line,col,code) order; source mapping retains existing one-per-code/source-location selection. Contract-free returns use today's path unchanged.
|
||||
|
||||
A virtual post-access error's primary span is its binding token, not ret; code-specific function/block/inst fields identify the installing post instruction. They are not additions to the common diagnostic envelope. Function and block are AIR names without sigils, as in ordinary borrow diagnostic payloads; inst is the zero-based instruction index. Map that binding independently to the source root occurrence in its clause. Preserve existing factual payload and conflict/spawn origins; result payloads name the actual ret operand, not a synthetic result ValueId. Add proposed code-specific fields `contract_binding` (zero-based argument index) and `contract_return` (the evaluated return position). The latter's field order is `function,block,inst`, followed by file/line/col only when exactly mapped, then mandatory air_line/air_col. Its block is a name, not an index; names/inst identify the actual ret and source coordinates map independently. This is a separate factual position object: today's related_locations roles require a value identity and cannot represent ret without inventing one. No role is silently added to that closed schema.
|
||||
|
||||
For AIR-only input, contract_return still includes air_line/air_col and omits file/line/col because no source lowering map exists; the primary envelope continues to identify the input AIR file. This deliberately differs from today's AIR-only related_locations serialization and must not be normalized by inventing a source map.
|
||||
|
||||
All returns are checked. Buffer only the new virtual facts and append them in increasing return block index, then instruction index, retaining clause/binding order within each return. The existing stable (line,col,code) sort therefore retains that return order within a tied virtual primary/code, before source duplicate selection; the current comparator itself supplies no return key. Internal block indices establish this order, while JSON records contain block names. Ordinary facts and contract-free ordering stay unchanged. Source may retain one representative failure for a binding across several returns or repeated mapped specializations under its existing code/location rule. This output selection does not suppress checking another clause or return. Distinct source clause bindings have distinct primary positions and survive independently. Future collection tests must cover two clauses failing with the same code at one ret, one clause failing at several returns, and duplicate imported/template maps, with the exact retained return context. No contract diagnostic fields are implemented by this candidate.
|
||||
|
||||
Current baselines at `8df6cac`: a wrong-origin borrow return with an unrelated live owner emits only E2102, while a valid-origin or scalar return retaining that owner emits E3002. Returning an already taken owner emits E2002. Returning an owner with a live child view emits both E2101 and E2105: the current return check kills the root after reporting its transfer conflict, then reports the view leak. Do not replace this with an invented first-error-only return contract. Future vectors must pair an otherwise valid ret's unavailable post root with an unrelated leak, proving both survive; a return-legality failure must preserve the baseline list and suppress dependent post errors. These are proposed collection rules, not an implemented post checker.
|
||||
|
||||
### Purity/stability witnesses
|
||||
|
||||
Reference in new issue
Block a user