cli: add whole-value linear aggregates

Implement STD-5 through source, AIR, verifier and deterministic interpreter.
Constructors consume nested owners; exhaustive unpack/take, explicit swap and
own.pack preserve ownership on success and failure. Support owning Option and
Result while keeping classification helpers Copy-only. Preserve borrow identity
across whole replacement and collection; distinguish individual owned arrays
from repeated heap arrays.

Specify feature contracts, invariants, diagnostics, compatibility and measured
source/AIR budgets in RFC 0023 and normative docs. Add canonical round trips,
AIR/source acceptance and rejection fixtures, CLI integration and CI checks.

Validate build, unit/extended tests, full conformance, forced-collection schedule
stress (32 seeds per quantum), hosted smoke, CLI suites, source coverage (88/88),
formatting and reference bundle generation. Source bundle grows 3.2%; Quick
Reference grows 4.0%. No MCC improvement is claimed.

Dynamic initialized linear buffers and explicit drain remain Q-036/STD-6;
frame/region/repeated heap storage is Copy-only. RFC remains Proposed.
This commit is contained in:
dev committed 2026-10-06 21:23:52 +03:00
1 parent 7eea31518d
commit 4f084decce
109 files changed
+1814 -142

No files matched your search

+17 -1
View File
@@ -407,6 +407,22 @@ fn main() -> u64 effects [] {
}
```
`std.option.Option<T: Copy>` has `some(T)`/`none`; `std.result.Result<T: Copy, E: Copy>` has `ok(T)`/`err(E)`. `is_some::<T>` and `is_ok::<T, E>` classify them; match to extract payloads. Owning/borrowed payloads still reject. Unknown names: `E7002`; missing/extra arguments, duplicate/unknown constraints or expansion limits: `E7006`; unsatisfied constraints: `E7005` with `parameter`, `constraint`, `found`. Borrow conflicts, moves, effects and cleanup keep their existing rules.
`std.option.Option<T>` has `some(T)`/`none`; `std.result.Result<T, E>` has `ok(T)`/`err(E)`. `is_some::<T>` and `is_ok::<T, E>` classify Copy specializations; match to extract payloads. Owning payloads follow §13; borrowed payloads reject. Unknown names: `E7002`; missing/extra arguments, duplicate/unknown constraints or expansion limits: `E7006`; unsatisfied constraints: `E7005` with `parameter`, `constraint`, `found`. Borrow conflicts, moves, effects and cleanup keep their existing rules.
Each required specialization is checked as concrete code; an unused template body is not a proof for future types. `Copy` gives no arithmetic or ordering operation. Read `/docs/language/generics.md` for exact Copy/Send/Share/Freeze/Local rules, deterministic keys and fixed limits; `/docs/library/std.md` for option/result contracts.
## 13. Linear aggregates
A struct/enum/fixed array containing owners or resources is linear. Construct with `move`; consume it completely. Read Copy fields normally. A linear enum needs exhaustive `match move`; even none must be consumed. No partial moves or automatic cleanup.
```aji
struct Item { owner: own<u64> }
fn main(heap: cap<mem.alloc>) -> u64 effects [mem.alloc] {
let owner = own.new(42u64, heap) or trap;
let value = Item { owner: move owner };
let (part) = struct.unpack(move value);
return own.take(move part);
}
```
`[move a, move b]` constructs ordered array elements; `let (a,b) = array.unpack(move data);` extracts every element. `value.swap(mut place, move replacement)` returns the old complete value. `own.pack(move value, heap)` has ok(owner) and err(error, original_value); own.take extracts linear content, while own.free cannot destroy it. Dynamic heap arrays/regions/frame storage remain Copy-only. Owning std.option/std.result use ordinary linear enums; is_some/is_ok retain Copy constraints. Full contracts: language/linear-aggregates.md.