aboutsummaryrefslogtreecommitdiff
path: root/src/value.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-10-20 14:03:55 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-10-20 14:03:55 -0700
commit328ec15d9cae0373c1f973699c392db5b63ab886 (patch)
tree2c81e060907538a5668ffe03b54a114b56e2fe03 /src/value.zig
parent6dc45e7d3186f81b1329c71b6380ff3ddd5dec41 (diff)
downloadzig-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/value.zig')
-rw-r--r--src/value.zig23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/value.zig b/src/value.zig
index 15289de6b2..2c4a88da17 100644
--- a/src/value.zig
+++ b/src/value.zig
@@ -701,20 +701,15 @@ pub const Value = struct {
}
},
.ErrorSet => {
- const bits = mod.errorSetBits();
- const byte_count: u16 = @intCast((@as(u17, bits) + 7) / 8);
-
+ // TODO revisit this when we have the concept of the error tag type
+ const Int = u16;
const name = switch (ip.indexToKey(val.toIntern())) {
.err => |err| err.name,
.error_union => |error_union| error_union.val.err_name,
else => unreachable,
};
- var bigint_buffer: BigIntSpace = undefined;
- const bigint = BigIntMutable.init(
- &bigint_buffer.limbs,
- mod.global_error_set.getIndex(name).?,
- ).toConst();
- bigint.writeTwosComplement(buffer[0..byte_count], endian);
+ const int = @as(Module.ErrorInt, @intCast(mod.global_error_set.getIndex(name).?));
+ std.mem.writeInt(Int, buffer[0..@sizeOf(Int)], @as(Int, @intCast(int)), endian);
},
.Union => switch (ty.containerLayout(mod)) {
.Auto => return error.IllDefinedMemoryLayout, // Sema is supposed to have emitted a compile error already
@@ -992,12 +987,10 @@ pub const Value = struct {
}
},
.ErrorSet => {
- const bits = mod.errorSetBits();
- const byte_count: u16 = @intCast((@as(u17, bits) + 7) / 8);
- const int = std.mem.readVarInt(u64, buffer[0..byte_count], endian);
- const index = (int << @as(u6, @intCast(64 - bits))) >> @as(u6, @intCast(64 - bits));
- const name = mod.global_error_set.keys()[@intCast(index)];
-
+ // TODO revisit this when we have the concept of the error tag type
+ const Int = u16;
+ const int = std.mem.readInt(Int, buffer[0..@sizeOf(Int)], endian);
+ const name = mod.global_error_set.keys()[@as(usize, @intCast(int))];
return (try mod.intern(.{ .err = .{
.ty = ty.toIntern(),
.name = name,