Sema: fix comparison between error set and comptime-known error union

Resolves: #20613
This commit is contained in:
mlugg
2025-02-05 20:13:56 +00:00
parent 9ba9f457be
commit cac814cf58
2 changed files with 19 additions and 1 deletions

View File

@@ -1100,3 +1100,14 @@ test "return error union with i65" {
fn add(x: i65, y: i65) anyerror!i65 {
return x + y;
}
test "compare error union to error set" {
const S = struct {
fn doTheTest(val: error{Foo}!i32) !void {
if (error.Foo == val) return error.Unexpected;
if (val == error.Foo) return error.Unexpected;
}
};
try S.doTheTest(0);
try comptime S.doTheTest(0);
}