authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-07-20 19:42:59-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-07-20 19:42:59-07:00
logd15dd78abd058b13c82156e5e19ec716e860889e
treed231afca0a7e1e366ac224033db3e27590f5fc38
parentbf09dd87b6bde0c7af6b9415661be07b250afa27

Sema: fix regression in merging error sets

When updating the code, I accidentally made it look at the fact that the error set operands were a `type` rather than looking at exactly which error set types they were.

1 files changed, 5 insertions(+), 5 deletions(-)

src/Sema.zig+5-5
......@@ -2625,9 +2625,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Com
26252625 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
26262626 const lhs = sema.resolveInst(extra.lhs);
26272627 const rhs = sema.resolveInst(extra.rhs);
2628 const lhs_ty = sema.typeOf(lhs);
2629 const rhs_ty = sema.typeOf(rhs);
2630 if (rhs_ty.zigTypeTag() == .Bool and lhs_ty.zigTypeTag() == .Bool) {
2628 if (sema.typeOf(lhs).zigTypeTag() == .Bool and sema.typeOf(rhs).zigTypeTag() == .Bool) {
26312629 const msg = msg: {
26322630 const msg = try sema.mod.errMsg(&block.base, lhs_src, "expected error set type, found 'bool'", .{});
26332631 errdefer msg.destroy(sema.gpa);
......@@ -2636,10 +2634,12 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Com
26362634 };
26372635 return sema.mod.failWithOwnedErrorMsg(&block.base, msg);
26382636 }
2639 if (rhs_ty.zigTypeTag() != .ErrorSet)
2640 return sema.mod.fail(&block.base, rhs_src, "expected error set type, found {}", .{rhs_ty});
2637 const lhs_ty = try sema.analyzeAsType(block, lhs_src, lhs);
2638 const rhs_ty = try sema.analyzeAsType(block, rhs_src, rhs);
26412639 if (lhs_ty.zigTypeTag() != .ErrorSet)
26422640 return sema.mod.fail(&block.base, lhs_src, "expected error set type, found {}", .{lhs_ty});
2641 if (rhs_ty.zigTypeTag() != .ErrorSet)
2642 return sema.mod.fail(&block.base, rhs_src, "expected error set type, found {}", .{rhs_ty});
26432643
26442644 // Anything merged with anyerror is anyerror.
26452645 if (lhs_ty.tag() == .anyerror or rhs_ty.tag() == .anyerror) {