From 98a01f99c9b6834608055417169c2b3531ea67b6 Mon Sep 17 00:00:00 2001 From: Veikka Tuominen Date: Sat, 12 Mar 2022 11:14:17 +0200 Subject: [PATCH] Sema: fix typo in resolvePeerTypes --- src/Sema.zig | 2 +- test/behavior/error.zig | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Sema.zig b/src/Sema.zig index 82acbab9e5..860d9d63ac 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -18910,7 +18910,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; diff --git a/test/behavior/error.zig b/test/behavior/error.zig index b3503051fb..93d76443ae 100644 --- a/test/behavior/error.zig +++ b/test/behavior/error.zig @@ -626,3 +626,11 @@ test "inferred error set equality" { try expect(BarError == BarError); try expect(BazError == BazError); } + +test "peer type resolution of two different error unions" { + const a: error{B}!void = {}; + const b: error{A}!void = {}; + var cond = true; + const err = if (cond) a else b; + try err; +}