spec: spell the AIR array type array<T, N>

';' starts a comment in text AIR, so [T; N] cannot be parsed. Recorded
as an erratum in RFC 0005; source syntax may keep [T; N].
This commit is contained in:
dev committed 2026-10-04 13:11:07 +03:00
1 parent 48bb50724f
commit be9dd0e1ed
7 files changed
+20 -19

No files matched your search

+2 -2
View File
@@ -256,14 +256,14 @@ Any other change to format 0 — a different meaning, typing rule, trap behavior
### 8.8 Types and syntax of the features `ownership` and `arrays`
Feature membership: `local<T>`, `ref<T>`, `mut<T>` and the `from` clause belong to `ownership`; `[T; N]`, `slice<T>`, `slice_mut<T>` and multi-result binding belong to `arrays`. Using them without declaring the feature is `E0006` reason `feature_not_declared`.
Feature membership: `local<T>`, `ref<T>`, `mut<T>` and the `from` clause belong to `ownership`; `array<T, N>`, `slice<T>`, `slice_mut<T>` and multi-result binding belong to `arrays`. Using them without declaring the feature is `E0006` reason `feature_not_declared`.
| Type | Class | Notes |
|---|---|---|
| `local<T>` | storage | frame storage holding a `T`; only an operand of `local.*` and `borrow.*` |
| `ref<T>` | borrow | shared borrow |
| `mut<T>` | borrow | exclusive borrow |
| `[T; N]` | value | array of `N` values, `1 ≤ N ≤ 2^32`; copyable when `T` is |
| `array<T, N>` | value | array of `N` values, `1 ≤ N ≤ 2^32`; copyable when `T` is |
| `slice<T>` | borrow | shared borrow of a contiguous range |
| `slice_mut<T>` | borrow | exclusive borrow of a contiguous range |
+3 -3
View File
@@ -193,10 +193,10 @@ Common contract unless stated: no effects, no capabilities, no synchronization.
| Instruction | Operands → result | Verifier | Runtime |
|---|---|---|---|
| `%a = array.splat [T; N] %v` | `T` → `[T; N]` | — | every element is `%v` |
| `%e = borrow.index %b, %i` | `ref`/`mut` of `[T; N]`, or `slice`/`slice_mut` of `T`; `usize` → `ref<T>`/`mut<T>` | child of `%b` | traps `T0008` if `%i ≥ length` |
| `%a = array.splat array<T, N> %v` | `T` → `array<T, N>` | — | every element is `%v` |
| `%e = borrow.index %b, %i` | `ref`/`mut` of `array<T, N>`, or `slice`/`slice_mut` of `T`; `usize` → `ref<T>`/`mut<T>` | child of `%b` | traps `T0008` if `%i ≥ length` |
| `%e = borrow.index.proven %b, %i` | as above | `%i < length` proven (spec 08 §12), otherwise `E2103` | no check |
| `%s = slice.make %b` | `ref<[T; N]>`/`mut<[T; N]>` → `slice<T>`/`slice_mut<T>` | child of `%b` | whole array |
| `%s = slice.make %b` | `ref<array<T, N>>`/`mut<array<T, N>>` → `slice<T>`/`slice_mut<T>` | child of `%b` | whole array |
| `%n = slice.len %s` | `slice<T>`/`slice_mut<T>` → `usize` | — | length |
| `%t = slice.sub %s, %start, %len` | slice, `usize`, `usize` → same slice type | child of `%s` | traps `T0008` unless `start ≤ slice.len(s)` and `len ≤ slice.len(s) − start` (evaluated without overflow); result covers `[start, start + len)` |
| `%l, %r = slice.split %s, %at` | slice, `usize` → two slices of the same type | two children of `%s`, disjoint | traps `T0008` unless `at ≤ slice.len(s)`; `l` covers `[0, at)`, `r` covers `[at, len)` |
+2 -2
View File
@@ -187,7 +187,7 @@ Each function's frame storage is the sum of the accounted sizes of its `local.al
| `usize`/`isize` | 8 (the largest supported pointer width, so the result is target-independent) |
| struct | sum of its fields |
| enum | 4 + the largest sum over a variant's payload |
| `[T; N]` | `N ×` accounted size of `T` |
| `array<T, N>` | `N ×` accounted size of `T` |
### 11.6 Borrow-typed block parameters
@@ -216,7 +216,7 @@ Scope of a fact:
| Case | Condition |
|---|---|
| fact on the same slice | a fact `%i < %n` holds where `%n = slice.len %b`, with `%i` and `%b` the same SSA values as the operands |
| constant index | `%i = const.usize k` and `%b` has a static length `N` (a borrow of `[T; N]`) with `k < N` |
| constant index | `%i = const.usize k` and `%b` has a static length `N` (a borrow of `array<T, N>`) with `k < N` |
| fact against a constant | a fact `%i < %n` holds where `%n = const.usize k`, `%b` has a static length `N` and `k ≤ N` |
This is the complete normative analysis: an implementation MUST NOT accept more or fewer programs.