cli: preserve whole-array arguments for explicit array parameters
This commit is contained in:
1 parent
f733f7c7bb
commit
dde801c653
44 files changed
+397
-9
No files matched your search
@@ -123,3 +123,11 @@ The invariant is one retained completion obligation per source scope, with every
|
||||
Valid: `scope s { let t = task.spawn(s, work); let s = 0u64; let n = task.join(move t); }`. Rejected: `scope s { let alias = move s; }` (E7006, existing reason `invalid_expression`, fields `name`/`type: scope`); plain aliases, yields, returns, aggregates and ordinary arguments are rejected likewise. Borrowing keeps `invalid_place`, assigning the immutable identifier keeps `invalid_assignment`, and a moved/non-scope spawn operand keeps E7005. The existing structured reason plus type identifies the category without reading prose; no additional reason is needed.
|
||||
|
||||
Compatibility: formerly accepted scope aliases, spawning through an alias or the apparently moved original, standalone scope names and block/scope tails now reject. Accepted shadowing, nested scope lookup, cleanup at fall-through/return/break/continue, and all AIR format-0 programs retain their meanings. Public source conformance covers accepted/rejected forms, specialized bodies and live children; CLI tests cover exact reasons/locations, packages and deterministic/hosted execution. Scheduler stress and per-instruction collection check cleanup. Source documentation growth is measured in docs/agent/README.md. The change improves explicitness and repairability without an empirical MCC claim; it does not finish P6-2.
|
||||
|
||||
## DD-021 — Whole-array arguments follow explicit parameter types
|
||||
|
||||
Q-023 is resolved in spec 15 §5: a temporary `ref`/`mut` argument preserves its array referent when the known parameter is an array borrow, including explicitly specialized calls. This is the existing small inference from one declared signature, with no overload search. It makes an already expressible parameter callable without hand-written AIR. Array bindings and slice parameters retain their slice behavior; bare byte strings retain their shorthand. Consequently, array-borrow origins and task loans require forwarding an existing array-borrow parameter; a local whole-array binding is still a slice.
|
||||
|
||||
Invariant: temporary children and ancestors remain live through the call, then end child first; no view escapes a temporary origin. Existing AIR type, aliasing, initialization, bounds, origin and task-loan verification remains authoritative. Runtime and deterministic interpreter rules are unchanged. Valid: `fn first(a: ref<[u64; 2]>) -> u64 effects [] { return a[0]; }` called with `first(ref data)` for a two-element array. A different length or explicit mode rejects E7005; overlapping exclusive/shared arguments reject E2101. Returning a view from an inline origin and lending an inline argument to a task retain E7006.
|
||||
|
||||
Compatibility: formerly rejected array-borrow calls become available; accepted source retains canonical AIR. No new syntax, AIR instruction/feature, diagnostic, verifier/runtime state, allocation or cleanup semantics. The frontend selects array versus slice using the parameter, then emits existing borrow/reborrow and end instructions. Source/AIR conformance and CLI checks cover projections, modes, specialization, packages and temporary cleanup. Source budget growth is recorded in docs/agent/README.md; AIR is unchanged. This improves explicitness and completes source access to an existing primitive without a measured MCC claim.
|
||||
@@ -179,6 +179,8 @@ A byte string lowers to one `local.zero`, then a borrow, index, store and end pe
|
||||
|
||||
In `.aji` a borrow of a whole array written as an argument (`f(ref a)`, `a: [u64; 4]`) is always lowered as a slice (`slice<u64>`), so a function declared with a parameter `ref<[u64; 4]>` cannot be called with `ref a` (`E7005`). Spec 15 §5 says that binding a borrow of a whole array (`ref r = a;`) gives a slice. It does not say what an argument borrow gives, so the frontend's choice is not specified. Options: the argument borrow follows the parameter type (array borrow for `ref<[T; N]>`, slice for `slice<T>`), which is a small amount of inference from a known signature; or keep slices only and state it in spec 15. Found while writing the interpreter memory test; not urgent.
|
||||
|
||||
**Resolved (DD-021, spec 15 §5):** an explicit temporary borrow preserves an array when the known ordinary-call parameter is an array borrow. Exact type/length/mode checks remain; slices, bindings, byte-string shorthand, retained origins and task loans keep their existing rules.
|
||||
|
||||
## Q-024 — Memory-model clarifications found by the independent oracle
|
||||
|
||||
The independent author of `tools/litmus/enumerate.py` (P5-1a) worked from spec 04 §20 only. It reported five points the text leaves implicit. For each, the author chose the RC11 reading, and all 20 corpus tests agree with the stated sets under it. Proposed clarifying text for spec 04 §20, for owner approval:
|
||||
|
||||
Reference in new issue
Block a user