diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-03-12 14:18:58 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-12 14:18:58 -0500 |
| commit | 5ff7b04a6ad72eb86b6d467dfdc25bea1a9ecf63 (patch) | |
| tree | a4bffd48c7c31b64af53425464e0c0c048156abf /src/Sema.zig | |
| parent | 01081ce5a59f4e2e57a9ff6e5885269ed3014279 (diff) | |
| parent | d532c21d890e1aa22cd4c57d6a3f749890256254 (diff) | |
| download | zig-5ff7b04a6ad72eb86b6d467dfdc25bea1a9ecf63.tar.gz zig-5ff7b04a6ad72eb86b6d467dfdc25bea1a9ecf63.zip | |
Merge pull request #11133 from Vexu/stage2
stage2: misc fixes on the way to `std.debug.dumpCurrentStackTrace`
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 82acbab9e5..d813cf374b 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -6972,7 +6972,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError return sema.failWithOwnedErrorMsg(block, msg); } - if (special_prong == .@"else") { + if (special_prong == .@"else" and seen_errors.count() == operand_ty.errorSetNames().len) { return sema.fail( block, special_prong_src, @@ -16692,6 +16692,13 @@ fn coerceInMemoryAllowedErrorSets( else => unreachable, } + if (dst_ies.func == sema.owner_func) { + // We are trying to coerce an error set to the current function's + // inferred error set. + try dst_ies.addErrorSet(sema.gpa, src_ty); + return .ok; + } + try sema.resolveInferredErrorSet(block, dest_src, dst_payload.data); // isAnyError might have changed from a false negative to a true positive after resolution. if (dest_ty.isAnyError()) { @@ -18910,7 +18917,7 @@ fn resolvePeerTypes( } const chosen_set_ty = err_set_ty orelse chosen_ty.errorUnionSet(); - const candidate_set_ty = chosen_ty.errorUnionSet(); + const candidate_set_ty = candidate_ty.errorUnionSet(); if (.ok == try sema.coerceInMemoryAllowedErrorSets(block, chosen_set_ty, candidate_set_ty, src, src)) { err_set_ty = chosen_set_ty; |
