diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-10-18 15:45:11 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-10-18 15:45:11 -0700 |
| commit | bea447a6378fbc65eb79f31c5f1770c75850074c (patch) | |
| tree | 95f989734bde6ec6232700933f308f3bf8ffc8e2 /src/type.zig | |
| parent | 75c8c4442d1dd6fe43fbef1bfeaded360a98fe51 (diff) | |
| download | zig-bea447a6378fbc65eb79f31c5f1770c75850074c.tar.gz zig-bea447a6378fbc65eb79f31c5f1770c75850074c.zip | |
stage2: fix coercion of error set to error union
When returning an error set or an error union from a function which has
an inferred error set, it populates the error names in addition to the
set of functions. This can have false negatives, meaning that after
checking the map of an unresolved error set, one must do full error set
resolution before emitting a compile error.
Diffstat (limited to 'src/type.zig')
| -rw-r--r-- | src/type.zig | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/type.zig b/src/type.zig index 324901faf0..2bf268bc5f 100644 --- a/src/type.zig +++ b/src/type.zig @@ -3869,6 +3869,11 @@ pub const Type = extern union { .error_set_inferred => { const func = err_set_ty.castTag(.error_set_inferred).?.data.func; try self.functions.put(gpa, func, {}); + var it = func.owner_decl.ty.fnReturnType().errorUnionSet() + .castTag(.error_set_inferred).?.data.map.iterator(); + while (it.next()) |entry| { + try self.map.put(gpa, entry.key_ptr.*, {}); + } }, .anyerror => { self.is_anyerror = true; |
