aboutsummaryrefslogtreecommitdiff
path: root/src/value.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-03-28 19:38:19 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-03-28 19:40:21 -0700
commit8f469c11275e60f5f1a8ae08fc7596ba366eda16 (patch)
tree0d6d8894eeb6f6ce42d7994d92c5df278ba436d9 /src/value.zig
parent0005b346375f1fbe7bc42c22d658e3218bbd599d (diff)
downloadzig-8f469c11275e60f5f1a8ae08fc7596ba366eda16.tar.gz
zig-8f469c11275e60f5f1a8ae08fc7596ba366eda16.zip
stage2: fix error sets
Diffstat (limited to 'src/value.zig')
-rw-r--r--src/value.zig47
1 files changed, 1 insertions, 46 deletions
diff --git a/src/value.zig b/src/value.zig
index 7e98d14a34..269cceafa4 100644
--- a/src/value.zig
+++ b/src/value.zig
@@ -102,7 +102,6 @@ pub const Value = extern union {
float_64,
float_128,
enum_literal,
- error_set,
@"error",
error_union,
/// This is a special value that tracks a set of types that have been stored
@@ -196,7 +195,6 @@ pub const Value = extern union {
.float_32 => Payload.Float_32,
.float_64 => Payload.Float_64,
.float_128 => Payload.Float_128,
- .error_set => Payload.ErrorSet,
.@"error" => Payload.Error,
.inferred_alloc => Payload.InferredAlloc,
};
@@ -404,7 +402,6 @@ pub const Value = extern union {
return Value{ .ptr_otherwise = &new_payload.base };
},
- .error_set => return self.copyPayloadShallow(allocator, Payload.ErrorSet),
.inferred_alloc => unreachable,
}
}
@@ -515,15 +512,6 @@ pub const Value = extern union {
.float_32 => return out_stream.print("{}", .{val.castTag(.float_32).?.data}),
.float_64 => return out_stream.print("{}", .{val.castTag(.float_64).?.data}),
.float_128 => return out_stream.print("{}", .{val.castTag(.float_128).?.data}),
- .error_set => {
- const error_set = val.castTag(.error_set).?.data;
- try out_stream.writeAll("error{");
- var it = error_set.fields.iterator();
- while (it.next()) |entry| {
- try out_stream.print("{},", .{entry.value});
- }
- return out_stream.writeAll("}");
- },
.@"error" => return out_stream.print("error.{s}", .{val.castTag(.@"error").?.data.name}),
// TODO to print this it should be error{ Set, Items }!T(val), but we need the type for that
.error_union => return out_stream.print("error_union_val({})", .{val.castTag(.error_union).?.data}),
@@ -608,10 +596,6 @@ pub const Value = extern union {
};
return Type.initPayload(&new.base);
},
- .error_set => {
- const payload = self.castTag(.error_set).?.data;
- return Type.Tag.error_set.create(allocator, payload.decl);
- },
.undef,
.zero,
@@ -711,7 +695,6 @@ pub const Value = extern union {
.unreachable_value,
.empty_array,
.enum_literal,
- .error_set,
.error_union,
.@"error",
.empty_struct_value,
@@ -799,7 +782,6 @@ pub const Value = extern union {
.unreachable_value,
.empty_array,
.enum_literal,
- .error_set,
.@"error",
.error_union,
.empty_struct_value,
@@ -887,7 +869,6 @@ pub const Value = extern union {
.unreachable_value,
.empty_array,
.enum_literal,
- .error_set,
.@"error",
.error_union,
.empty_struct_value,
@@ -1003,7 +984,6 @@ pub const Value = extern union {
.unreachable_value,
.empty_array,
.enum_literal,
- .error_set,
.@"error",
.error_union,
.empty_struct_value,
@@ -1095,7 +1075,6 @@ pub const Value = extern union {
.unreachable_value,
.empty_array,
.enum_literal,
- .error_set,
.@"error",
.error_union,
.empty_struct_value,
@@ -1256,7 +1235,6 @@ pub const Value = extern union {
.void_value,
.unreachable_value,
.enum_literal,
- .error_set,
.@"error",
.error_union,
.empty_struct_value,
@@ -1335,7 +1313,6 @@ pub const Value = extern union {
.unreachable_value,
.empty_array,
.enum_literal,
- .error_set,
.@"error",
.error_union,
.empty_struct_value,
@@ -1476,15 +1453,10 @@ pub const Value = extern union {
.enum_literal_type,
.ty,
=> {
- // Directly return Type.hash, toType can only fail for .int_type and .error_set.
+ // Directly return Type.hash, toType can only fail for .int_type.
var allocator = std.heap.FixedBufferAllocator.init(&[_]u8{});
return (self.toType(&allocator.allocator) catch unreachable).hash();
},
- .error_set => {
- // Payload.decl should be same for all instances of the type.
- const payload = self.castTag(.error_set).?.data;
- std.hash.autoHash(&hasher, payload.decl);
- },
.int_type => {
const payload = self.castTag(.int_type).?.data;
var int_payload = Type.Payload.Bits{
@@ -1656,7 +1628,6 @@ pub const Value = extern union {
.unreachable_value,
.empty_array,
.enum_literal,
- .error_set,
.@"error",
.error_union,
.empty_struct_value,
@@ -1744,7 +1715,6 @@ pub const Value = extern union {
.void_value,
.unreachable_value,
.enum_literal,
- .error_set,
.@"error",
.error_union,
.empty_struct_value,
@@ -1849,7 +1819,6 @@ pub const Value = extern union {
.float_128,
.void_value,
.enum_literal,
- .error_set,
.@"error",
.error_union,
.empty_struct_value,
@@ -1933,7 +1902,6 @@ pub const Value = extern union {
.float_128,
.void_value,
.enum_literal,
- .error_set,
.empty_struct_value,
=> null,
@@ -2012,7 +1980,6 @@ pub const Value = extern union {
.single_const_pointer_to_comptime_int_type,
.const_slice_u8_type,
.enum_literal_type,
- .error_set,
=> true,
.zero,
@@ -2156,18 +2123,6 @@ pub const Value = extern union {
data: f128,
};
- /// TODO move to type.zig
- pub const ErrorSet = struct {
- pub const base_tag = Tag.error_set;
-
- base: Payload = .{ .tag = base_tag },
- data: struct {
- /// TODO revisit this when we have the concept of the error tag type
- fields: std.StringHashMapUnmanaged(void),
- decl: *Module.Decl,
- },
- };
-
pub const Error = struct {
base: Payload = .{ .tag = .@"error" },
data: struct {