spec: accept RFC 0005 and integrate Phase 1 memory model (P1-1, P1-2)

- RFC 0005 Accepted (revision 2)
- spec 07 §8.8 types and syntax; spec 07a contracts for features
  ownership and arrays; spec 08 §11-§14 borrows, facts, initialization,
  stage order; spec 03 frame storage, second-class borrows, static
  region generations
- grammar: from-returns, multi-result, new types and opcodes
- feature registry: ownership and arrays published; heap added and
  regions moved to Phase 2; borrow_joins reserved and unscheduled
- codes E2105-E2108, T0008
- Q-009, Q-010 resolved; Phase 1 and Phase 2 plans updated; Own test
  moved to phase 2
This commit is contained in:
dev committed 2026-10-04 13:10:08 +03:00
1 parent 2c84c0c7cf
commit 48bb50724f
15 files changed
+269 -55

No files matched your search

+11 -8
View File
@@ -17,19 +17,21 @@ pub const Feature = struct {
name: []const u8,
depends: []const []const u8,
status: Status,
/// Plan phase that publishes the feature.
phase: u8,
/// Plan phase that publishes the feature; null if unscheduled.
phase: ?u8,
};
pub const registry = [_]Feature{
.{ .name = "arrays", .depends = &.{}, .status = .reserved, .phase = 1 },
.{ .name = "arrays", .depends = &.{"ownership"}, .status = .published, .phase = 1 },
.{ .name = "atomics", .depends = &.{"ownership"}, .status = .reserved, .phase = 5 },
.{ .name = "borrow_joins", .depends = &.{"ownership"}, .status = .reserved, .phase = null },
.{ .name = "capabilities", .depends = &.{ "effects", "ownership" }, .status = .reserved, .phase = 2 },
.{ .name = "channels", .depends = &.{"ownership"}, .status = .reserved, .phase = 3 },
.{ .name = "effects", .depends = &.{}, .status = .reserved, .phase = 2 },
.{ .name = "islands", .depends = &.{ "ownership", "regions" }, .status = .reserved, .phase = 4 },
.{ .name = "ownership", .depends = &.{}, .status = .reserved, .phase = 1 },
.{ .name = "regions", .depends = &.{"ownership"}, .status = .reserved, .phase = 1 },
.{ .name = "heap", .depends = &.{ "capabilities", "effects", "ownership" }, .status = .reserved, .phase = 2 },
.{ .name = "islands", .depends = &.{ "capabilities", "effects", "ownership", "regions" }, .status = .reserved, .phase = 4 },
.{ .name = "ownership", .depends = &.{}, .status = .published, .phase = 1 },
.{ .name = "regions", .depends = &.{ "capabilities", "effects", "ownership" }, .status = .reserved, .phase = 2 },
.{ .name = "sync", .depends = &.{"ownership"}, .status = .reserved, .phase = 3 },
.{ .name = "tasks", .depends = &.{"ownership"}, .status = .reserved, .phase = 3 },
};
@@ -142,7 +144,7 @@ test "registry is sorted, closed under dependencies and acyclic" {
const dep = find(&registry, d) orelse return error.UnknownDependency;
// Dependencies are themselves closed: a feature lists its full closure.
for (dep.depends) |dd| try std.testing.expect(contains(f.depends, dd));
try std.testing.expect(dep.phase <= f.phase);
if (f.phase) |fp| try std.testing.expect(dep.phase != null and dep.phase.? <= fp);
try std.testing.expect(!contains(dep.depends, f.name));
}
}
@@ -160,7 +162,8 @@ test "registry mirrors docs/reference/air-features.md" {
var cols = std.mem.tokenizeScalar(u8, line, '|');
const name = std.mem.trim(u8, cols.next().?, " `");
const status = std.mem.trim(u8, cols.next().?, " ");
const phase = try std.fmt.parseInt(u8, std.mem.trim(u8, cols.next().?, " "), 10);
const phase_text = std.mem.trim(u8, cols.next().?, " ");
const phase: ?u8 = if (std.mem.eql(u8, phase_text, "—")) null else try std.fmt.parseInt(u8, phase_text, 10);
const deps_text = std.mem.trim(u8, cols.next().?, " ");
const f = find(&registry, name) orelse {
std.debug.print("feature {s} is in air-features.md but not in the registry\n", .{name});
+5
View File
@@ -35,6 +35,10 @@ pub const registry = [_]Code{
.{ .id = "E2102", .kind = "borrow.outlives_owner", .meaning = "Borrow may outlive backing storage" },
.{ .id = "E2103", .kind = "memory.out_of_bounds", .meaning = "Access not proven in bounds" },
.{ .id = "E2104", .kind = "memory.region_generation", .meaning = "Reference belongs to invalidated region generation" },
.{ .id = "E2105", .kind = "borrow.not_ended", .meaning = "Owned borrow live at `ret`, or borrow state differs between edges into a block" },
.{ .id = "E2106", .kind = "borrow.use_after_end", .meaning = "Borrow used or ended after it was ended" },
.{ .id = "E2107", .kind = "borrow.not_owned", .meaning = "Lent (parameter) borrow ended by the callee" },
.{ .id = "E2108", .kind = "borrow.escapes_frame", .meaning = "Borrow derived from frame storage returned from its function" },
.{ .id = "E2110", .kind = "island.escape", .meaning = "Island-internal reference escapes island" },
.{ .id = "E2111", .kind = "island.foreign_mutable_edge", .meaning = "Island graph points to forbidden foreign mutable storage" },
// E3xxx — Resources/capabilities/effects
@@ -66,6 +70,7 @@ pub const registry = [_]Code{
.{ .id = "T0005", .kind = "trap.shift_out_of_range", .meaning = "Shift amount negative or not less than bit width" },
.{ .id = "T0006", .kind = "trap.cast_out_of_range", .meaning = "Checked cast value not representable in target type" },
.{ .id = "T0007", .kind = "trap.call_depth", .meaning = "Call depth limit (1 024 frames) exceeded" },
.{ .id = "T0008", .kind = "trap.out_of_bounds", .meaning = "Runtime bounds check failed" },
};
pub fn lookup(id: []const u8) ?*const Code {