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:
109 files changed
+1814
-142
No files matched your search
@@ -42,7 +42,7 @@ Declaring `features [capabilities, effects, ownership]` grants no authority. It
|
||||
| `guard_transfer` | reserved | — | `cancellation`, `effects`, `ownership`, `sync`, `tasks` | `guard<T>` as parameter, return type or aggregate member; unscheduled |
|
||||
| `heap` | published | 2 | `capabilities`, `effects`, `ownership`, `resources` | `own<T>`, `own_array<T>`, `own.*`, built-in `alloc_error`, `mem.alloc` budgets and `budget` narrowing (spec 03 §18–§19) |
|
||||
| `islands` | published | 4 | `capabilities`, `effects`, `heap`, `ownership`, `resources` | `island<T>`, `frozen<T>`, `iref<T>`, `island.*`, `frozen.*`, `iref.eq`, `IslandSafe`, `T0010` (spec 03 §22–§23) |
|
||||
| `linear_aggregates` | reserved | — | `capabilities`, `effects`, `ownership`, `resources` | resource types as struct fields, enum payloads and array elements; unscheduled |
|
||||
| `linear_aggregates` | published | 6 | `capabilities`, `effects`, `ownership`, `resources` | whole-value linear structs/enums/fixed arrays, unpack/take/swap and ownership-preserving own.pack; spec 03 §25 |
|
||||
| `ownership` | published | 1 | — | frame storage `local<T>`, second-class borrows `ref<T>`/`mut<T>`, `from` returns, initialization (spec 07 §8.8, spec 07a, spec 08 §11, §13) |
|
||||
| `receiver_dup` | reserved | — | `cancellation`, `capabilities`, `channels`, `effects`, `heap`, `ownership`, `resources`, `tasks` | several receivers of one channel (MPMC); unscheduled |
|
||||
| `regions` | published | 2 | `capabilities`, `effects`, `heap`, `ownership`, `resources` | `region`, `region.*`, static generations (spec 03 §20) |
|
||||
|
||||
@@ -65,6 +65,7 @@ operation = "const." int_type int_lit
|
||||
| "struct.get" global "." ident "," local
|
||||
| "enum.make" global "." ident "(" [ local_list ] ")"
|
||||
| "call" global "(" [ local_list ] ")"
|
||||
| linear_aggregate_op
|
||||
| ownership_op
|
||||
| arrays_op
|
||||
| capability_op
|
||||
@@ -240,3 +241,11 @@ int_lit = [ "-" ] ( dec_digits | "0x" hex_digits | "0b" bin_digits ) ;
|
||||
(* "_" may separate digits; it carries no meaning. *)
|
||||
version_lit = digit { digit } "." digit { digit } ;
|
||||
string = '"' { string_char | '\\"' | '\\\\' | '\\n' } '"' ; (* not empty; only in `trusted` *)
|
||||
|
||||
(* Feature linear_aggregates, spec 03 §25 and spec 07a. *)
|
||||
linear_aggregate_op = "array.make" type "(" [ local_list ] ")"
|
||||
| "struct.unpack" global local "," "next" "->" global
|
||||
| "array.unpack" type local "," "next" "->" global
|
||||
| "enum.take" global local "," enum_arm { "," enum_arm }
|
||||
| "value.swap" local "," local
|
||||
| "own.pack" type local "," local ok_err ;
|
||||
@@ -57,7 +57,7 @@ statement = "let" binding [ ":" type ] "=" expr ";"
|
||||
| "break" ";" | "continue" ";" | "return" [ expr ] ";" | "trap" ";"
|
||||
| expr ";"
|
||||
| block_stmt ;
|
||||
binding = ident | "(" ident "," ident ")" ; (* the pair form only for `split_at` *)
|
||||
binding = ident | "(" [ ( ident | "_" ) { "," ( ident | "_" ) } ] ")" ; (* complete unpack; pairs also split_at/compare_exchange *)
|
||||
block_stmt = if_expr | match_expr | select_stmt | block
|
||||
| "while" expr block
|
||||
| "for" ident "in" expr ".." expr block
|
||||
@@ -94,9 +94,11 @@ postfix = primary { application | "." member | "[" expr [ ".." expr ] "]"
|
||||
member = ident | keyword ; (* after `.` a keyword is a name: task.cancelled *)
|
||||
call_args = [ "<" type ">" ] "(" [ expr { "," expr } ] ")" ;
|
||||
primary = int_lit | "true" | "false" | string
|
||||
| "struct" "." "unpack" (* contextual built-in call, §16 *)
|
||||
| ident | path [ application ] "{" [ field_init { "," field_init } [ "," ] ] "}" (* struct literal; uppercase final component *)
|
||||
| path [ application ] "::" ident (* enum variant; applied by a call *)
|
||||
| "[" expr ";" int_lit "]"
|
||||
| "[" expr { "," expr } [ "," ] "]"
|
||||
| "(" expr ")"
|
||||
| if_expr | match_expr | block ;
|
||||
field_init = ident ":" expr ;
|
||||
|
||||
@@ -221,9 +221,9 @@ Requires direct `import std.option;` / `import std.result;`; explicit generic sp
|
||||
|
||||
| Declaration | Contract |
|
||||
|---|---|
|
||||
| `std.option.Option<T: Copy>` | `some(T)`, `none` |
|
||||
| `std.option.Option<T>` | `some(T)`, `none` |
|
||||
| `std.option.is_some<T: Copy>(value: Option<T>) -> bool` | true for some; false for none; effects [] |
|
||||
| `std.result.Result<T: Copy, E: Copy>` | `ok(T)`, `err(E)` |
|
||||
| `std.result.Result<T, E>` | `ok(T)`, `err(E)` |
|
||||
| `std.result.is_ok<T: Copy, E: Copy>(value: Result<T, E>) -> bool` | true for ok; false for err; effects [] |
|
||||
|
||||
All are ordinary safe source/static specialization, with no allocation or authority. Generic helper calls use `is_some::<u64>(value)` / `is_ok::<u64, u8>(value)`. Constructors and patterns use `std.option.Option::<u64>::some(value)` or `std.result.Result::<u64, u8>::err(code)`; names and variant matches remain explicit even for none. Extract values by exhaustive match; an err variant is not intrinsic outcome syntax. Owners/resources/endpoints and borrows fail Copy constraints with E7005, until a separate linear-aggregate feature supplies their contracts. No must-use or implicit unwrap/default/conversion is introduced. [Checked example](../../examples/std/generics.aji) returns 42 without grants.
|
||||
All are ordinary safe source/static specialization, with no allocation or authority. Generic helper calls use `is_some::<u64>(value)` / `is_ok::<u64, u8>(value)`. Constructors and patterns use `std.option.Option::<u64>::some(value)` or `std.result.Result::<u64, u8>::err(code)`; names and variant matches remain explicit even for none. Extract values by exhaustive match; an err variant is not intrinsic outcome syntax. Owners/resources/endpoints make these enums linear under spec 03 §25 and require exhaustive `match move`. Borrows remain invalid members; Copy classification helpers reject linear arguments with E7005. No must-use or implicit unwrap/default/conversion is introduced. [Checked example](../../examples/std/generics.aji) returns 42 without grants.
|
||||
@@ -53,3 +53,5 @@ An `ArcSafe` value may be held by an `arc` (spec 03 §24): the last release dest
|
||||
## Format-0 source constraints
|
||||
|
||||
Spec 15 §15 fixes the exact property queries used by explicit generic specialization. Copy includes integers, booleans, built-in enums, capabilities, `iref` and aggregates of Copy members; borrows and linear values are excluded. Send/Share use spec 04 §35. Freeze currently equals IslandSafe plain graph content; it does not promise conversion of arbitrary owners or resources. Local has task/scope/shield/guard/internal-storage base cases and propagates through borrow/own/own_array/mutex wrappers and arrays/aggregates containing Local content. It is not the complement of Send. These properties add no methods, effects, unsafe declarations or implicit resource actions.
|
||||
|
||||
Under linear_aggregates (spec 03 §25), structs/enums/fixed arrays containing any linear member are linear as whole values. Every variant contributes, regardless of the active tag. Borrow/storage/function-bound members remain forbidden; whole-value unpack/take/exchange preserve exactly-once consumption.
|
||||
Reference in new issue
Block a user