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`.
This commit is contained in:
Andrew Kelley
2021-10-17 14:50:47 -07:00
parent 53b87fa78a
commit 6534f2ef4f
5 changed files with 146 additions and 45 deletions

View File

@@ -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(),