From 6534f2ef4f8161f4121326f19bc3cf89324f62c5 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 17 Oct 2021 14:50:47 -0700 Subject: stage2: implement error wrapping * Sema: fix returned operands not coercing to the function return type in some cases. - When returning an error or an error union from a function with an inferred error set, it will now populate the inferred error set. - Implement error set coercion for the common case of inferred error set to inferred error set, without forcing a full resolution. * LLVM backend: update instruction lowering that handles error unions to respect `isByRef`. - Also implement `wrap_err_union_err`. --- src/Module.zig | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index a42ec3c2e1..f52e1c8ef7 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -782,6 +782,10 @@ pub const ErrorSet = struct { /// The length is given by `names_len`. names_ptr: [*]const []const u8, + pub fn names(self: ErrorSet) []const []const u8 { + return self.names_ptr[0..self.names_len]; + } + pub fn srcLoc(self: ErrorSet) SrcLoc { return .{ .file_scope = self.owner_decl.getFileScope(), -- cgit v1.2.3