authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-11-15 13:03:48+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-11-15 13:03:48+02:00
logf173d078c780c9946742c4ce686ccd0dccdb7e98
tree47cf88dce1e9f9d4db80290aec4ff5234845defb
parent643f526cd121173b4102ce3a07ee9bb4a1582cc2
signaturelock-open Commit is signed but in an unrecognized format.

stage2: outline container types


6 files changed, 298 insertions(+), 3 deletions(-)

src/Module.zig+29-1
...@@ -428,7 +428,7 @@ pub const Scope = struct {...@@ -428,7 +428,7 @@ pub const Scope = struct {
428 };428 };
429 }429 }
430430
431 /// Asserts the scope has a parent which is a ZIRModule, Contaienr or File and431 /// Asserts the scope has a parent which is a ZIRModule, Container or File and
432 /// returns the sub_file_path field.432 /// returns the sub_file_path field.
433 pub fn subFilePath(base: *Scope) []const u8 {433 pub fn subFilePath(base: *Scope) []const u8 {
434 switch (base.tag) {434 switch (base.tag) {
...@@ -1515,6 +1515,7 @@ pub fn analyzeContainer(self: *Module, container_scope: *Scope.Container) !void...@@ -1515,6 +1515,7 @@ pub fn analyzeContainer(self: *Module, container_scope: *Scope.Container) !void
1515 // an incremental update. This code handles both cases.1515 // an incremental update. This code handles both cases.
1516 const tree = try self.getAstTree(container_scope);1516 const tree = try self.getAstTree(container_scope);
1517 const decls = tree.root_node.decls();1517 const decls = tree.root_node.decls();
1518 // const decls = container_scope.root_node.decls();
15181519
1519 try self.comp.work_queue.ensureUnusedCapacity(decls.len);1520 try self.comp.work_queue.ensureUnusedCapacity(decls.len);
1520 try container_scope.decls.ensureCapacity(self.gpa, decls.len);1521 try container_scope.decls.ensureCapacity(self.gpa, decls.len);
...@@ -2272,6 +2273,33 @@ pub fn createAnonymousDecl(...@@ -2272,6 +2273,33 @@ pub fn createAnonymousDecl(
2272 return new_decl;2273 return new_decl;
2273}2274}
22742275
2276fn createContainerDecl(self: *Module, scope: *Scope, container_node: *std.zig.ast.Node.ContainerDecl) !*Decl {
2277 const name = try self.getAnonTypeName(scope, container_node.kind_token);
2278 defer self.gpa.free(name);
2279 const name_hash = scope.namespace().fullyQualifiedNameHash(name);
2280 const src_hash: std.zig.SrcHash = undefined;
2281 const new_decl = try self.createNewDecl(scope, name, scope_decl.src_index, name_hash, src_hash);
2282 const decl_arena_state = try decl_arena.allocator.create(std.heap.ArenaAllocator.State);
2283
2284 decl_arena_state.* = decl_arena.state;
2285 new_decl.generation = self.generation;
2286
2287 return new_decl;
2288}
2289
2290fn getAnonTypeName(self: *Module, scope: *Scope, base_token: std.zig.ast.TokenIndex) ![]u8 {
2291 const container = scope.getContainer();
2292 const tree = self.getAstTree(container);
2293 const base_name = switch (tree.token_ids[base_token]) {
2294 .Keyword_struct => "struct",
2295 .Keyword_enum => "enum",
2296 .Keyword_union => "union",
2297 else => unreachable,
2298 };
2299 const loc = tree.tokenLocationLoc(0, tree.token_locs[base_token]);
2300 return std.fmt.allocPrint(self.gpa, "{}:{}:{}", .{ base_name, loc.line, loc.column });
2301}
2302
2275fn getNextAnonNameIndex(self: *Module) usize {2303fn getNextAnonNameIndex(self: *Module) usize {
2276 return @atomicRmw(usize, &self.next_anon_name_index, .Add, 1, .Monotonic);2304 return @atomicRmw(usize, &self.next_anon_name_index, .Add, 1, .Monotonic);
2277}2305}
src/type.zig+98-1
...@@ -90,7 +90,9 @@ pub const Type = extern union {...@@ -90,7 +90,9 @@ pub const Type = extern union {
9090
91 .anyframe_T, .@"anyframe" => return .AnyFrame,91 .anyframe_T, .@"anyframe" => return .AnyFrame,
9292
93 .empty_struct => return .Struct,93 .@"struct", .empty_struct => return .Struct,
94 .@"enum" => return .Enum,
95 .@"union" => return .Union,
94 }96 }
95 }97 }
9698
...@@ -442,6 +444,11 @@ pub const Type = extern union {...@@ -442,6 +444,11 @@ pub const Type = extern union {
442 .error_set => return self.copyPayloadShallow(allocator, Payload.ErrorSet),444 .error_set => return self.copyPayloadShallow(allocator, Payload.ErrorSet),
443 .error_set_single => return self.copyPayloadShallow(allocator, Payload.ErrorSetSingle),445 .error_set_single => return self.copyPayloadShallow(allocator, Payload.ErrorSetSingle),
444 .empty_struct => return self.copyPayloadShallow(allocator, Payload.EmptyStruct),446 .empty_struct => return self.copyPayloadShallow(allocator, Payload.EmptyStruct),
447
448 // memory managed by the decl
449 .@"enum" => return self,
450 .@"struct" => return self,
451 .@"union" => return self,
445 }452 }
446 }453 }
447454
...@@ -673,6 +680,10 @@ pub const Type = extern union {...@@ -673,6 +680,10 @@ pub const Type = extern union {
673 const payload = @fieldParentPtr(Payload.ErrorSetSingle, "base", ty.ptr_otherwise);680 const payload = @fieldParentPtr(Payload.ErrorSetSingle, "base", ty.ptr_otherwise);
674 return out_stream.print("error{{{}}}", .{payload.name});681 return out_stream.print("error{{{}}}", .{payload.name});
675 },682 },
683 // TODO improve
684 .@"enum" => return out_stream.writeAll("enum {}"),
685 .@"struct" => return out_stream.writeAll("struct {}"),
686 .@"union" => return out_stream.writeAll("union {}"),
676 }687 }
677 unreachable;688 unreachable;
678 }689 }
...@@ -784,6 +795,10 @@ pub const Type = extern union {...@@ -784,6 +795,10 @@ pub const Type = extern union {
784 return payload.error_set.hasCodeGenBits() or payload.payload.hasCodeGenBits();795 return payload.error_set.hasCodeGenBits() or payload.payload.hasCodeGenBits();
785 },796 },
786797
798 .@"enum" => @panic("TODO"),
799 .@"struct" => @panic("TODO"),
800 .@"union" => @panic("TODO"),
801
787 .c_void,802 .c_void,
788 .void,803 .void,
789 .type,804 .type,
...@@ -908,6 +923,10 @@ pub const Type = extern union {...@@ -908,6 +923,10 @@ pub const Type = extern union {
908 @panic("TODO abiAlignment error union");923 @panic("TODO abiAlignment error union");
909 },924 },
910925
926 .@"enum" => self.cast(Payload.Enum).?.abiAlignment(),
927 .@"struct" => @panic("TODO"),
928 .@"union" => @panic("TODO"),
929
911 .c_void,930 .c_void,
912 .void,931 .void,
913 .type,932 .type,
...@@ -1050,6 +1069,10 @@ pub const Type = extern union {...@@ -1050,6 +1069,10 @@ pub const Type = extern union {
1050 }1069 }
1051 @panic("TODO abiSize error union");1070 @panic("TODO abiSize error union");
1052 },1071 },
1072
1073 .@"enum" => @panic("TODO"),
1074 .@"struct" => @panic("TODO"),
1075 .@"union" => @panic("TODO"),
1053 };1076 };
1054 }1077 }
10551078
...@@ -1117,6 +1140,9 @@ pub const Type = extern union {...@@ -1117,6 +1140,9 @@ pub const Type = extern union {
1117 .error_set,1140 .error_set,
1118 .error_set_single,1141 .error_set_single,
1119 .empty_struct,1142 .empty_struct,
1143 .@"enum",
1144 .@"struct",
1145 .@"union",
1120 => false,1146 => false,
11211147
1122 .single_const_pointer,1148 .single_const_pointer,
...@@ -1192,6 +1218,9 @@ pub const Type = extern union {...@@ -1192,6 +1218,9 @@ pub const Type = extern union {
1192 .error_set,1218 .error_set,
1193 .error_set_single,1219 .error_set_single,
1194 .empty_struct,1220 .empty_struct,
1221 .@"enum",
1222 .@"struct",
1223 .@"union",
1195 => false,1224 => false,
11961225
1197 .const_slice,1226 .const_slice,
...@@ -1264,6 +1293,9 @@ pub const Type = extern union {...@@ -1264,6 +1293,9 @@ pub const Type = extern union {
1264 .error_set,1293 .error_set,
1265 .error_set_single,1294 .error_set_single,
1266 .empty_struct,1295 .empty_struct,
1296 .@"enum",
1297 .@"struct",
1298 .@"union",
1267 => false,1299 => false,
12681300
1269 .single_const_pointer,1301 .single_const_pointer,
...@@ -1345,6 +1377,9 @@ pub const Type = extern union {...@@ -1345,6 +1377,9 @@ pub const Type = extern union {
1345 .error_set,1377 .error_set,
1346 .error_set_single,1378 .error_set_single,
1347 .empty_struct,1379 .empty_struct,
1380 .@"enum",
1381 .@"struct",
1382 .@"union",
1348 => false,1383 => false,
13491384
1350 .pointer => {1385 .pointer => {
...@@ -1421,6 +1456,9 @@ pub const Type = extern union {...@@ -1421,6 +1456,9 @@ pub const Type = extern union {
1421 .error_set,1456 .error_set,
1422 .error_set_single,1457 .error_set_single,
1423 .empty_struct,1458 .empty_struct,
1459 .@"enum",
1460 .@"struct",
1461 .@"union",
1424 => false,1462 => false,
14251463
1426 .pointer => {1464 .pointer => {
...@@ -1539,6 +1577,9 @@ pub const Type = extern union {...@@ -1539,6 +1577,9 @@ pub const Type = extern union {
1539 .error_set,1577 .error_set,
1540 .error_set_single,1578 .error_set_single,
1541 .empty_struct,1579 .empty_struct,
1580 .@"enum",
1581 .@"struct",
1582 .@"union",
1542 => unreachable,1583 => unreachable,
15431584
1544 .array => self.cast(Payload.Array).?.elem_type,1585 .array => self.cast(Payload.Array).?.elem_type,
...@@ -1667,6 +1708,9 @@ pub const Type = extern union {...@@ -1667,6 +1708,9 @@ pub const Type = extern union {
1667 .error_set,1708 .error_set,
1668 .error_set_single,1709 .error_set_single,
1669 .empty_struct,1710 .empty_struct,
1711 .@"enum",
1712 .@"struct",
1713 .@"union",
1670 => unreachable,1714 => unreachable,
16711715
1672 .array => self.cast(Payload.Array).?.len,1716 .array => self.cast(Payload.Array).?.len,
...@@ -1733,6 +1777,9 @@ pub const Type = extern union {...@@ -1733,6 +1777,9 @@ pub const Type = extern union {
1733 .error_set,1777 .error_set,
1734 .error_set_single,1778 .error_set_single,
1735 .empty_struct,1779 .empty_struct,
1780 .@"enum",
1781 .@"struct",
1782 .@"union",
1736 => unreachable,1783 => unreachable,
17371784
1738 .single_const_pointer,1785 .single_const_pointer,
...@@ -1816,6 +1863,9 @@ pub const Type = extern union {...@@ -1816,6 +1863,9 @@ pub const Type = extern union {
1816 .error_set,1863 .error_set,
1817 .error_set_single,1864 .error_set_single,
1818 .empty_struct,1865 .empty_struct,
1866 .@"enum",
1867 .@"struct",
1868 .@"union",
1819 => false,1869 => false,
18201870
1821 .int_signed,1871 .int_signed,
...@@ -1891,6 +1941,9 @@ pub const Type = extern union {...@@ -1891,6 +1941,9 @@ pub const Type = extern union {
1891 .error_set,1941 .error_set,
1892 .error_set_single,1942 .error_set_single,
1893 .empty_struct,1943 .empty_struct,
1944 .@"enum",
1945 .@"struct",
1946 .@"union",
1894 => false,1947 => false,
18951948
1896 .int_unsigned,1949 .int_unsigned,
...@@ -1956,6 +2009,9 @@ pub const Type = extern union {...@@ -1956,6 +2009,9 @@ pub const Type = extern union {
1956 .error_set,2009 .error_set,
1957 .error_set_single,2010 .error_set_single,
1958 .empty_struct,2011 .empty_struct,
2012 .@"enum",
2013 .@"struct",
2014 .@"union",
1959 => unreachable,2015 => unreachable,
19602016
1961 .int_unsigned => .{ .signed = false, .bits = self.cast(Payload.IntUnsigned).?.bits },2017 .int_unsigned => .{ .signed = false, .bits = self.cast(Payload.IntUnsigned).?.bits },
...@@ -2039,6 +2095,9 @@ pub const Type = extern union {...@@ -2039,6 +2095,9 @@ pub const Type = extern union {
2039 .error_set,2095 .error_set,
2040 .error_set_single,2096 .error_set_single,
2041 .empty_struct,2097 .empty_struct,
2098 .@"enum",
2099 .@"struct",
2100 .@"union",
2042 => false,2101 => false,
20432102
2044 .usize,2103 .usize,
...@@ -2151,6 +2210,9 @@ pub const Type = extern union {...@@ -2151,6 +2210,9 @@ pub const Type = extern union {
2151 .error_set,2210 .error_set,
2152 .error_set_single,2211 .error_set_single,
2153 .empty_struct,2212 .empty_struct,
2213 .@"enum",
2214 .@"struct",
2215 .@"union",
2154 => unreachable,2216 => unreachable,
2155 };2217 };
2156 }2218 }
...@@ -2229,6 +2291,9 @@ pub const Type = extern union {...@@ -2229,6 +2291,9 @@ pub const Type = extern union {
2229 .error_set,2291 .error_set,
2230 .error_set_single,2292 .error_set_single,
2231 .empty_struct,2293 .empty_struct,
2294 .@"enum",
2295 .@"struct",
2296 .@"union",
2232 => unreachable,2297 => unreachable,
2233 }2298 }
2234 }2299 }
...@@ -2306,6 +2371,9 @@ pub const Type = extern union {...@@ -2306,6 +2371,9 @@ pub const Type = extern union {
2306 .error_set,2371 .error_set,
2307 .error_set_single,2372 .error_set_single,
2308 .empty_struct,2373 .empty_struct,
2374 .@"enum",
2375 .@"struct",
2376 .@"union",
2309 => unreachable,2377 => unreachable,
2310 }2378 }
2311 }2379 }
...@@ -2383,6 +2451,9 @@ pub const Type = extern union {...@@ -2383,6 +2451,9 @@ pub const Type = extern union {
2383 .error_set,2451 .error_set,
2384 .error_set_single,2452 .error_set_single,
2385 .empty_struct,2453 .empty_struct,
2454 .@"enum",
2455 .@"struct",
2456 .@"union",
2386 => unreachable,2457 => unreachable,
2387 };2458 };
2388 }2459 }
...@@ -2457,6 +2528,9 @@ pub const Type = extern union {...@@ -2457,6 +2528,9 @@ pub const Type = extern union {
2457 .error_set,2528 .error_set,
2458 .error_set_single,2529 .error_set_single,
2459 .empty_struct,2530 .empty_struct,
2531 .@"enum",
2532 .@"struct",
2533 .@"union",
2460 => unreachable,2534 => unreachable,
2461 };2535 };
2462 }2536 }
...@@ -2531,6 +2605,9 @@ pub const Type = extern union {...@@ -2531,6 +2605,9 @@ pub const Type = extern union {
2531 .error_set,2605 .error_set,
2532 .error_set_single,2606 .error_set_single,
2533 .empty_struct,2607 .empty_struct,
2608 .@"enum",
2609 .@"struct",
2610 .@"union",
2534 => unreachable,2611 => unreachable,
2535 };2612 };
2536 }2613 }
...@@ -2605,6 +2682,9 @@ pub const Type = extern union {...@@ -2605,6 +2682,9 @@ pub const Type = extern union {
2605 .error_set,2682 .error_set,
2606 .error_set_single,2683 .error_set_single,
2607 .empty_struct,2684 .empty_struct,
2685 .@"enum",
2686 .@"struct",
2687 .@"union",
2608 => false,2688 => false,
2609 };2689 };
2610 }2690 }
...@@ -2664,6 +2744,10 @@ pub const Type = extern union {...@@ -2664,6 +2744,10 @@ pub const Type = extern union {
2664 .error_set_single,2744 .error_set_single,
2665 => return null,2745 => return null,
26662746
2747 .@"enum" => @panic("TODO onePossibleValue enum"),
2748 .@"struct" => @panic("TODO onePossibleValue struct"),
2749 .@"union" => @panic("TODO onePossibleValue union"),
2750
2667 .empty_struct => return Value.initTag(.empty_struct_value),2751 .empty_struct => return Value.initTag(.empty_struct_value),
2668 .void => return Value.initTag(.void_value),2752 .void => return Value.initTag(.void_value),
2669 .noreturn => return Value.initTag(.unreachable_value),2753 .noreturn => return Value.initTag(.unreachable_value),
...@@ -2773,6 +2857,9 @@ pub const Type = extern union {...@@ -2773,6 +2857,9 @@ pub const Type = extern union {
2773 .error_set,2857 .error_set,
2774 .error_set_single,2858 .error_set_single,
2775 .empty_struct,2859 .empty_struct,
2860 .@"enum",
2861 .@"struct",
2862 .@"union",
2776 => return false,2863 => return false,
27772864
2778 .c_const_pointer,2865 .c_const_pointer,
...@@ -2861,6 +2948,9 @@ pub const Type = extern union {...@@ -2861,6 +2948,9 @@ pub const Type = extern union {
2861 => unreachable,2948 => unreachable,
28622949
2863 .empty_struct => self.cast(Type.Payload.EmptyStruct).?.scope,2950 .empty_struct => self.cast(Type.Payload.EmptyStruct).?.scope,
2951 .@"enum" => &self.cast(Type.Payload.Enum).?.scope,
2952 .@"struct" => &self.cast(Type.Payload.Struct).?.scope,
2953 .@"union" => &self.cast(Type.Payload.Union).?.scope,
2864 };2954 };
2865 }2955 }
28662956
...@@ -3012,6 +3102,9 @@ pub const Type = extern union {...@@ -3012,6 +3102,9 @@ pub const Type = extern union {
3012 error_set,3102 error_set,
3013 error_set_single,3103 error_set_single,
3014 empty_struct,3104 empty_struct,
3105 @"enum",
3106 @"struct",
3107 @"union",
30153108
3016 pub const last_no_payload_tag = Tag.const_slice_u8;3109 pub const last_no_payload_tag = Tag.const_slice_u8;
3017 pub const no_payload_count = @enumToInt(last_no_payload_tag) + 1;3110 pub const no_payload_count = @enumToInt(last_no_payload_tag) + 1;
...@@ -3127,6 +3220,10 @@ pub const Type = extern union {...@@ -3127,6 +3220,10 @@ pub const Type = extern union {
31273220
3128 scope: *Module.Scope.Container,3221 scope: *Module.Scope.Container,
3129 };3222 };
3223
3224 pub const Enum = @import("value/Enum.zig");
3225 pub const Struct = @import("value/Struct.zig");
3226 pub const Union = @import("value/Union.zig");
3130 };3227 };
3131};3228};
31323229
src/type/Enum.zig created+55
...@@ -0,0 +1,55 @@
1const std = @import("std");
2const Value = @import("../value.zig").Value;
3const Type = @import("../type.zig").Type;
4const Module = @import("../Module.zig");
5const Scope = Module.Scope;
6
7base: Type.Payload = .{ .tag = .@"enum" },
8
9analysis: union(enum) {
10 queued: Zir,
11 in_progress,
12 resolved: Size,
13 failed,
14},
15
16pub const Field = struct {
17 value: Value,
18};
19
20pub const Zir = struct {
21 body: zir.Module.Body,
22 inst: *zir.Inst,
23 arena: std.heap.ArenaAllocator.State,
24};
25
26pub const Size = struct {
27 is_zero_bits: bool,
28 alignment: u32,
29 size: u32,
30 fields: std.AutoArrayHashMap([]const u8, Field),
31};
32
33pub fn resolve(self: *Enum, mod: *Module, scope: *Scope) !void {
34 const zir = switch (self.analysis) {
35 .failed => return error.AnalysisFail,
36 .resolved => return,
37 .in_progress => {
38 return mod.fail(scope, src, "enum '{}' depends on itself", .{enum_name});
39 },
40 .queued => |zir| zir,
41 };
42 self.analysis = .in_progress;
43
44 // TODO
45}
46
47// TODO should this resolve the type or assert that it has already been resolved?
48pub fn abiAlignment(self: *Enum) u32 {
49 switch (self.analysis) {
50 .queued => unreachable, // alignment has not been resolved
51 .in_progress => unreachable, // alignment has not been resolved
52 .failed => unreachable, // type resolution failed
53 .resolved => |r| return r.tag_type.abiAlignment(),
54 }
55}
src/type/Struct.zig created+57
...@@ -0,0 +1,57 @@
1const std = @import("std");
2const Value = @import("../value.zig").Value;
3const Type = @import("../type.zig").Type;
4const Module = @import("../Module.zig");
5const Scope = Module.Scope;
6
7base: Type.Payload = .{ .tag = .@"struct" },
8
9analysis: union(enum) {
10 queued: Zir,
11 zero_bits_in_progress,
12 zero_bits: Zero,
13 in_progress,
14 alignment: Align,
15 resolved: Size,
16 failed,
17},
18scope: Scope.Container,
19
20pub const Field = struct {
21 value: Value,
22};
23
24pub const Zir = struct {
25 body: zir.Module.Body,
26 inst: *zir.Inst,
27 arena: std.heap.ArenaAllocator.State,
28};
29
30pub const Zero = struct {
31 is_zero_bits: bool,
32 fields: std.AutoArrayHashMap([]const u8, Field),
33};
34
35pub const Size = struct {
36 is_zero_bits: bool,
37 alignment: u32,
38 size: u32,
39 fields: std.AutoArrayHashMap([]const u8, Field),
40};
41
42pub fn resolveZeroBits(self: *Enum, mod: *Module, scope: *Scope) !void {
43 const zir = switch (self.analysis) {
44 .failed => return error.AnalysisFail,
45 .zero_bits_in_progress => {
46 return mod.fail(scope, src, "union '{}' depends on itself", .{});
47 },
48 .queued => |zir| zir,
49 else => return,
50 };
51
52 self.analysis = .zero_bits_in_progress;
53
54 // TODO
55}
56
57pub fn resolveSize(self: *Enum,)
\ No newline at end of file
src/type/Union.zig created+57
...@@ -0,0 +1,57 @@
1const std = @import("std");
2const Value = @import("../value.zig").Value;
3const Type = @import("../type.zig").Type;
4const Module = @import("../Module.zig");
5const Scope = Module.Scope;
6
7base: Type.Payload = .{ .tag = .@"struct" },
8
9analysis: union(enum) {
10 queued: Zir,
11 zero_bits_in_progress,
12 zero_bits: Zero,
13 in_progress,
14 alignment: Align,
15 resolved: Size,
16 failed,
17},
18scope: Scope.Container,
19
20pub const Field = struct {
21 value: Value,
22};
23
24pub const Zir = struct {
25 body: zir.Module.Body,
26 inst: *zir.Inst,
27 arena: std.heap.ArenaAllocator.State,
28};
29
30pub const Zero = struct {
31 is_zero_bits: bool,
32 fields: std.AutoArrayHashMap([]const u8, Field),
33};
34
35pub const Size = struct {
36 is_zero_bits: bool,
37 alignment: u32,
38 size: u32,
39 fields: std.AutoArrayHashMap([]const u8, Field),
40};
41
42pub fn resolveZeroBits(self: *Enum, mod: *Module, scope: *Scope) !void {
43 const zir = switch (self.analysis) {
44 .failed => return error.AnalysisFail,
45 .zero_bits_in_progress => {
46 return mod.fail(scope, src, "union '{}' depends on itself", .{});
47 },
48 .queued => |zir| zir,
49 else => return,
50 };
51
52 self.analysis = .zero_bits_in_progress;
53
54 // TODO
55}
56
57pub fn resolveSize(self: *Enum,)
\ No newline at end of file
src/value.zig+2-1
...@@ -252,7 +252,7 @@ pub const Value = extern union {...@@ -252,7 +252,7 @@ pub const Value = extern union {
252 .@"error" => return self.copyPayloadShallow(allocator, Payload.Error),252 .@"error" => return self.copyPayloadShallow(allocator, Payload.Error),
253253
254 // memory is managed by the declaration254 // memory is managed by the declaration
255 .error_set => return self.copyPayloadShallow(allocator, Payload.ErrorSet),255 .error_set => return self,
256 }256 }
257 }257 }
258258
...@@ -1865,6 +1865,7 @@ pub const Value = extern union {...@@ -1865,6 +1865,7 @@ pub const Value = extern union {
1865 val: f128,1865 val: f128,
1866 };1866 };
18671867
1868 // TODO move to type.zig
1868 pub const ErrorSet = struct {1869 pub const ErrorSet = struct {
1869 base: Payload = .{ .tag = .error_set },1870 base: Payload = .{ .tag = .error_set },
18701871