diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-10-20 14:03:55 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-10-20 14:03:55 -0700 |
| commit | 328ec15d9cae0373c1f973699c392db5b63ab886 (patch) | |
| tree | 2c81e060907538a5668ffe03b54a114b56e2fe03 /src/type.zig | |
| parent | 6dc45e7d3186f81b1329c71b6380ff3ddd5dec41 (diff) | |
| download | zig-328ec15d9cae0373c1f973699c392db5b63ab886.tar.gz zig-328ec15d9cae0373c1f973699c392db5b63ab886.zip | |
Revert "make distinct error limit configurable"
This reverts commit 78855bd21866b515018259a2194e036e4b3120df.
This commit did not replace uses of `Type.err_int` of which there are
currently 60 uses.
Re-opens #786
Diffstat (limited to 'src/type.zig')
| -rw-r--r-- | src/type.zig | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/src/type.zig b/src/type.zig index 49582bd3c8..5bdca27667 100644 --- a/src/type.zig +++ b/src/type.zig @@ -905,11 +905,8 @@ pub const Type = struct { .opt_type => return abiAlignmentAdvancedOptional(ty, mod, strat), .error_union_type => |info| return abiAlignmentAdvancedErrorUnion(ty, mod, strat, info.payload_type.toType()), - .error_set_type, .inferred_error_set_type => { - const bits = mod.errorSetBits(); - if (bits == 0) return AbiAlignmentAdvanced{ .scalar = .@"1" }; - return .{ .scalar = intAbiAlignment(bits, target) }; - }, + // TODO revisit this when we have the concept of the error tag type + .error_set_type, .inferred_error_set_type => return .{ .scalar = .@"2" }, // represents machine code; not a pointer .func_type => |func_type| return .{ @@ -970,11 +967,10 @@ pub const Type = struct { else => return .{ .scalar = .@"16" }, }, - .anyerror, .adhoc_inferred_error_set => { - const bits = mod.errorSetBits(); - if (bits == 0) return AbiAlignmentAdvanced{ .scalar = .@"1" }; - return .{ .scalar = intAbiAlignment(bits, target) }; - }, + // TODO revisit this when we have the concept of the error tag type + .anyerror, + .adhoc_inferred_error_set, + => return .{ .scalar = .@"2" }, .void, .type, @@ -1288,11 +1284,8 @@ pub const Type = struct { .opt_type => return ty.abiSizeAdvancedOptional(mod, strat), - .error_set_type, .inferred_error_set_type => { - const bits = mod.errorSetBits(); - if (bits == 0) return AbiSizeAdvanced{ .scalar = 0 }; - return AbiSizeAdvanced{ .scalar = intAbiSize(bits, target) }; - }, + // TODO revisit this when we have the concept of the error tag type + .error_set_type, .inferred_error_set_type => return AbiSizeAdvanced{ .scalar = 2 }, .error_union_type => |error_union_type| { const payload_ty = error_union_type.payload_type.toType(); @@ -1386,11 +1379,10 @@ pub const Type = struct { .enum_literal, => return AbiSizeAdvanced{ .scalar = 0 }, - .anyerror, .adhoc_inferred_error_set => { - const bits = mod.errorSetBits(); - if (bits == 0) return AbiSizeAdvanced{ .scalar = 0 }; - return AbiSizeAdvanced{ .scalar = intAbiSize(bits, target) }; - }, + // TODO revisit this when we have the concept of the error tag type + .anyerror, + .adhoc_inferred_error_set, + => return AbiSizeAdvanced{ .scalar = 2 }, .prefetch_options => unreachable, // missing call to resolveTypeFields .export_options => unreachable, // missing call to resolveTypeFields @@ -1584,7 +1576,8 @@ pub const Type = struct { return (try abiSizeAdvanced(ty, mod, strat)).scalar * 8; }, - .error_set_type, .inferred_error_set_type => return mod.errorSetBits(), + // TODO revisit this when we have the concept of the error tag type + .error_set_type, .inferred_error_set_type => return 16, .error_union_type => { // Optionals and error unions are not packed so their bitsize @@ -1617,9 +1610,10 @@ pub const Type = struct { .bool => return 1, .void => return 0, + // TODO revisit this when we have the concept of the error tag type .anyerror, .adhoc_inferred_error_set, - => return mod.errorSetBits(), + => return 16, .anyopaque => unreachable, .type => unreachable, @@ -2178,7 +2172,8 @@ pub const Type = struct { while (true) switch (ty.toIntern()) { .anyerror_type, .adhoc_inferred_error_set_type => { - return .{ .signedness = .unsigned, .bits = mod.errorSetBits() }; + // TODO revisit this when error sets support custom int types + return .{ .signedness = .unsigned, .bits = 16 }; }, .usize_type => return .{ .signedness = .unsigned, .bits = target.ptrBitWidth() }, .isize_type => return .{ .signedness = .signed, .bits = target.ptrBitWidth() }, @@ -2197,9 +2192,8 @@ pub const Type = struct { .enum_type => |enum_type| ty = enum_type.tag_ty.toType(), .vector_type => |vector_type| ty = vector_type.child.toType(), - .error_set_type, .inferred_error_set_type => { - return .{ .signedness = .unsigned, .bits = mod.errorSetBits() }; - }, + // TODO revisit this when error sets support custom int types + .error_set_type, .inferred_error_set_type => return .{ .signedness = .unsigned, .bits = 16 }, .anon_struct_type => unreachable, |
