aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-07-20 19:42:59 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-07-20 19:42:59 -0700
commitd15dd78abd058b13c82156e5e19ec716e860889e (patch)
treed231afca0a7e1e366ac224033db3e27590f5fc38 /src/Sema.zig
parentbf09dd87b6bde0c7af6b9415661be07b250afa27 (diff)
downloadzig-d15dd78abd058b13c82156e5e19ec716e860889e.tar.gz
zig-d15dd78abd058b13c82156e5e19ec716e860889e.zip
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.
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 826097c3d1..59534cb74a 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -2625,9 +2625,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Com
const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
const lhs = sema.resolveInst(extra.lhs);
const rhs = sema.resolveInst(extra.rhs);
- const lhs_ty = sema.typeOf(lhs);
- const rhs_ty = sema.typeOf(rhs);
- if (rhs_ty.zigTypeTag() == .Bool and lhs_ty.zigTypeTag() == .Bool) {
+ if (sema.typeOf(lhs).zigTypeTag() == .Bool and sema.typeOf(rhs).zigTypeTag() == .Bool) {
const msg = msg: {
const msg = try sema.mod.errMsg(&block.base, lhs_src, "expected error set type, found 'bool'", .{});
errdefer msg.destroy(sema.gpa);
@@ -2636,10 +2634,12 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Com
};
return sema.mod.failWithOwnedErrorMsg(&block.base, msg);
}
- if (rhs_ty.zigTypeTag() != .ErrorSet)
- return sema.mod.fail(&block.base, rhs_src, "expected error set type, found {}", .{rhs_ty});
+ const lhs_ty = try sema.analyzeAsType(block, lhs_src, lhs);
+ const rhs_ty = try sema.analyzeAsType(block, rhs_src, rhs);
if (lhs_ty.zigTypeTag() != .ErrorSet)
return sema.mod.fail(&block.base, lhs_src, "expected error set type, found {}", .{lhs_ty});
+ if (rhs_ty.zigTypeTag() != .ErrorSet)
+ return sema.mod.fail(&block.base, rhs_src, "expected error set type, found {}", .{rhs_ty});
// Anything merged with anyerror is anyerror.
if (lhs_ty.tag() == .anyerror or rhs_ty.tag() == .anyerror) {