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...@@ -2625,9 +2625,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Com
2625 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };2625 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
2626 const lhs = sema.resolveInst(extra.lhs);2626 const lhs = sema.resolveInst(extra.lhs);
2627 const rhs = sema.resolveInst(extra.rhs);2627 const rhs = sema.resolveInst(extra.rhs);
2628 const lhs_ty = sema.typeOf(lhs);2628 if (sema.typeOf(lhs).zigTypeTag() == .Bool and sema.typeOf(rhs).zigTypeTag() == .Bool) {
2629 const rhs_ty = sema.typeOf(rhs);
2630 if (rhs_ty.zigTypeTag() == .Bool and lhs_ty.zigTypeTag() == .Bool) {
2631 const msg = msg: {2629 const msg = msg: {
2632 const msg = try sema.mod.errMsg(&block.base, lhs_src, "expected error set type, found 'bool'", .{});2630 const msg = try sema.mod.errMsg(&block.base, lhs_src, "expected error set type, found 'bool'", .{});
2633 errdefer msg.destroy(sema.gpa);2631 errdefer msg.destroy(sema.gpa);
...@@ -2636,10 +2634,12 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Com...@@ -2636,10 +2634,12 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Com
2636 };2634 };
2637 return sema.mod.failWithOwnedErrorMsg(&block.base, msg);2635 return sema.mod.failWithOwnedErrorMsg(&block.base, msg);
2638 }2636 }
2639 if (rhs_ty.zigTypeTag() != .ErrorSet)2637 const lhs_ty = try sema.analyzeAsType(block, lhs_src, lhs);
2640 return sema.mod.fail(&block.base, rhs_src, "expected error set type, found {}", .{rhs_ty});2638 const rhs_ty = try sema.analyzeAsType(block, rhs_src, rhs);
2641 if (lhs_ty.zigTypeTag() != .ErrorSet)2639 if (lhs_ty.zigTypeTag() != .ErrorSet)
2642 return sema.mod.fail(&block.base, lhs_src, "expected error set type, found {}", .{lhs_ty});2640 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
2644 // Anything merged with anyerror is anyerror.2644 // Anything merged with anyerror is anyerror.
2645 if (lhs_ty.tag() == .anyerror or rhs_ty.tag() == .anyerror) {2645 if (lhs_ty.tag() == .anyerror or rhs_ty.tag() == .anyerror) {