aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-07-07 20:47:21 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-07-07 20:47:21 -0700
commitc2e66d9bab396a69514ec7c3c41fb0404e542f21 (patch)
treefbc8b06cd459cd5e4ad2b39384c9d5d73e25c8ee /src/type.zig
parent5c8bd443d92c6306f60857720103ae46ca7b8b3e (diff)
downloadzig-c2e66d9bab396a69514ec7c3c41fb0404e542f21.tar.gz
zig-c2e66d9bab396a69514ec7c3c41fb0404e542f21.zip
stage2: basic inferred error set support
* Inferred error sets are stored in the return Type of the function, owned by the Module.Fn. So it cleans up that memory in deinit(). * Sema: update the inferred error set in zirRetErrValue - Update relevant code in wrapErrorUnion * C backend: improve some some instructions to take advantage of liveness analysis to avoid being emitted when unused. * C backend: when an error union has a payload type with no runtime bits, emit the error union as the same type as the error set.
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/type.zig b/src/type.zig
index f9385e90bc..e8f0998332 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -1041,7 +1041,7 @@ pub const Type = extern union {
return writer.writeAll(std.mem.spanZ(error_set.owner_decl.name));
},
.error_set_inferred => {
- const func = ty.castTag(.error_set_inferred).?.data;
+ const func = ty.castTag(.error_set_inferred).?.data.func;
return writer.print("(inferred error set of {s})", .{func.owner_decl.name});
},
.error_set_single => {
@@ -3154,7 +3154,10 @@ pub const Type = extern union {
pub const base_tag = Tag.error_set_inferred;
base: Payload = Payload{ .tag = base_tag },
- data: *Module.Fn,
+ data: struct {
+ func: *Module.Fn,
+ map: std.StringHashMapUnmanaged(void),
+ },
};
pub const Pointer = struct {