Phase 2: effects and capabilities (RFC 0006)

- air: cap<K> and built-in enums (cap_error) as types; enum.switch over
  built-in enums; cap.narrow terminator with ok/err targets; intrinsic
  syntax (registry still empty: E0004); registries for effects,
  capability kinds and built-in enums, synced with reference docs
- verifier: effect stage (E3101, flat, direct callees); cap.narrow form
  check (E3202) and ok/err parameter rules (E5002, E1001); capabilities
  are copyable, not zeroable, not comparable; sizes cap 8, built-in tag
- interp: host authority table; @main instantiation from grants by
  parameter name with not_instantiated reasons; capabilities render as
  opaque
- CLI: --grant P=KIND[:SCOPE], exit code 6; runner: grant: and
  not_instantiated: headers, pending only for unsupported features
- conformance: 18 Phase 2 tests; 4000 mutants without a crash
This commit is contained in:
dev committed 2026-10-04 13:42:35 +03:00
1 parent fb4338cea6
commit 9c29a80b72
41 files changed
+908 -58

No files matched your search

+15 -3
View File
@@ -102,6 +102,8 @@ pub fn printType(m: air.Module, t: air.Type, w: *Writer) Writer.Error!void {
try printType(m, a.elem, w);
try w.print(", {d}>", .{a.len});
},
.cap => |k| try w.print("cap<{s}>", .{air.authority.kinds[k].name}),
.builtin => |b| try w.writeAll(@tagName(b)),
.bool, .void, .never => try w.writeAll(@tagName(t)),
}
}
@@ -226,10 +228,11 @@ fn printOp(m: air.Module, f: air.Function, op: air.Op, w: *Writer) Writer.Error!
try target(f, x.default, w);
},
.enum_switch => |x| {
const d = m.types[x.decl];
try w.print("enum.switch @{s} ", .{d.name});
try w.writeAll("enum.switch ");
try printType(m, x.ty, w);
try w.writeByte(' ');
try value(f, x.value, w);
for (x.arms) |a| try w.print(", {s} -> @{s}", .{ d.kind.@"enum"[a.variant].name, f.blocks[a.block].name });
for (x.arms) |a| try w.print(", {s} -> @{s}", .{ m.variantName(x.ty, a.variant), f.blocks[a.block].name });
if (x.default) |dt| {
try w.writeAll(", default -> ");
try target(f, dt, w);
@@ -277,6 +280,15 @@ fn printOp(m: air.Module, f: air.Function, op: air.Op, w: *Writer) Writer.Error!
.slice_split => |x| try two(f, w, "slice.split", x.slice, x.at),
.slice_copy => |x| try two(f, w, "slice.copy", x.dst, x.src),
.guard => |v| try one(f, w, "guard", v),
.cap_narrow => |x| {
try w.print("cap.narrow.{s} ", .{x.form});
try value(f, x.cap, w);
for (x.args) |a| {
try w.writeAll(", ");
try value(f, a, w);
}
try w.print(", ok -> @{s}, err -> @{s}", .{ f.blocks[x.ok].name, f.blocks[x.err].name });
},
}
}