diag: guide parameter mutability and explicit array slice arguments
This commit is contained in:
1 parent
6a02659f31
commit
9549a3dec6
22 files changed
+197
-4
No files matched your search
@@ -178,3 +178,5 @@ P6-7 factual source E4202 fields (cl100k): Quick Reference stays 8,955; other so
|
||||
Spec 15 scope corrections (cl100k): Quick Reference stays 8,955 tokens despite the E1002 → E7005 correction; other source docs 68,353 → 68,403 (+50), full source 77,308 → 77,358 (+0.06%). o200k full source grows 77,547 → 77,594 (+47); Qwen2.5 79,257 → 79,315 (+58). AIR and std are unchanged. Existing source diagnostics, unpacking, escapes, buffers and borrow returns replace obsolete baseline descriptions; no semantic or implementation change.
|
||||
|
||||
Pointer-sized cast guidance (2026-10-09): Quick Reference grows 9,255 → 9,276 cl100k (+21); other source docs 69,817 → 69,863 (+46), full source 79,072 → 79,139 (+67, +0.085%). o200k grows by the same +21/+46/+67 (full 79,373); Qwen2.5 by +21/+47/+68 (full 81,127). AIR grows 188,993 → 189,078 bytes and +22 tokens for each tokenizer (48,398 cl100k / 48,551 o200k / 49,956 Qwen2.5). The existing target-independent ban on usize/isize widening is explained in the registered numeric-cast hint and source cast table. No new concept, syntax, feature, diagnostic code/kind or verifier/runtime state is introduced. Pointer identity casts now reject with source E7005/advice before AIR E1002; the accepted set is unchanged. No empirical reduction in repair rounds is claimed.
|
||||
|
||||
Parameter/array-call advice (2026-10-09): Quick Reference grows 9,276 → 9,360 cl100k (+84); other source docs 69,863 → 70,167 (+304), full source 79,139 → 79,527 (+388, +0.49%). o200k grows +84/+303/+387 (full 79,760); Qwen2.5 +84/+308/+392 (full 81,519). AIR grows 189,078 → 190,503 bytes, +304/+303/+308 tokens respectively (48,702 cl100k / 48,854 o200k / 50,264 Qwen2.5). Two registered advice kinds distinguish parameter ownership choices and explicit array-to-slice argument borrows; applicability and fixed prefix units account for the growth. No new syntax, semantic concept, code, feature or verifier/runtime state is added; existing envelopes/rejection priority and accepted lowerings remain unchanged. No empirical repair-round benefit is claimed.
|
||||
@@ -12,6 +12,7 @@ Aji makes every significant action explicit — moves, borrows, allocation, clos
|
||||
| a narrowing `x as T` | `x as! T` checks/traps; `x as% T` wraps |
|
||||
| `let mut x = value` / `var x = value` | `var x: T = value;` (type required) |
|
||||
| immutable `let x = value` | `let x = value;` (type may be inferred) |
|
||||
| `fn f(mut x: T)` | `fn f(x: T)` with a local `var`, or `fn f(x: mut<T>)` for an exclusive borrow; choose the ownership contract |
|
||||
| mutable/shared slice type | `slice_mut<T>` / `slice<T>` |
|
||||
| `s[start..]` | `s[start..end]` (explicit upper bound) |
|
||||
| `f(&x)` / `f(&mut x)` | `f(ref x)` / `f(mut x)` |
|
||||
@@ -118,6 +119,7 @@ Rules (checked by the verifier):
|
||||
|
||||
- **A borrow lives until the end of the block where it was bound** (`ref r = …;` / `mut r = …;`). A borrow written as an argument (`f(mut buf)`) lives for that call. To end one early, put it in an inner `{ … }` block.
|
||||
- A whole-array argument `f(ref a)` / `f(mut a)` preserves the array for a `ref<[T; N]>` / `mut<[T; N]>` parameter; otherwise it becomes a slice. Length and mode must match. Bound array borrows remain slices.
|
||||
- An array value is not a slice argument: use `f(ref a)` for `slice<T>` or `f(mut a)` for `slice_mut<T>`; the place and loan must verify.
|
||||
- **Exclusive XOR shared.** While a `mut` borrow of a place is live, no other borrow of the same place, and no direct use of it, is allowed (`E2101`). Disjoint fields and `split_at` halves are independent.
|
||||
- A borrow cannot outlive what it borrows from (`E2102`). A function returns a borrow only with explicit `from param`. Bind returned views with `ref`/`mut`; the `from` argument must be a named borrow. Return the bound name without `move`; a local-frame view cannot escape (`E2108`).
|
||||
- **Moves are explicit:** a named linear value is consumed only as `move x` (otherwise `E7003`). A fresh temporary needs no `move`: `consume(make())`. Copyable values are passed plainly; `move` on them is `E7006`.
|
||||
|
||||
Reference in new issue
Block a user