cli: add explicit built-in error values
Add the error_values feature and error.const through specification, AIR, verification, interpretation and source lowering. Error values are Copy data with no allocation, effects or authority. Keep enum.make semantics frozen. Cover all registered tags, feature negotiation, payload/type errors and authority rejection in AIR/source; verify canonical and hosted CLI behavior. Record reference-bundle costs and the map preflight-validation prerequisite.
This commit is contained in:
1 parent
89c63c306b
commit
1eaf968f4f
56 files changed
+823
-4
No files matched your search
@@ -258,6 +258,7 @@ const FnCtx = struct {
|
||||
fn resultType(m: air.Module, op: air.Op) ?Type {
|
||||
return switch (op) {
|
||||
.@"const" => |x| x.ty,
|
||||
.error_const => |x| .{ .builtin = x.which },
|
||||
.arith => |x| .{ .int = x.ty },
|
||||
.bit => |x| x.ty,
|
||||
.cmp => .bool,
|
||||
@@ -794,6 +795,7 @@ fn checkInst(fc: *FnCtx, inst: air.Inst) !void {
|
||||
const span = inst.span;
|
||||
switch (inst.op) {
|
||||
.@"const", .trap => {},
|
||||
.error_const => |x| if (x.variant >= x.which.variants().len) try fc.c.report("E1001", span, "invalid built-in error variant", &.{}),
|
||||
.copy => |v| if (!fc.typeOf(v).isValue() or m.isLinearType(fc.typeOf(v))) try fc.c.report("E1001", span, "only value types can be copied", &.{
|
||||
.{ .name = "function", .value = .{ .str = f.name } },
|
||||
.{ .name = "found", .value = .{ .str = try fc.c.typeName(fc.typeOf(v)) } },
|
||||
|
||||
Reference in new issue
Block a user