mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
Sema: fix else branch check when switching on error set
This commit is contained in:
parent
98a01f99c9
commit
07cc2fce2a
@ -6972,7 +6972,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
|
||||
return sema.failWithOwnedErrorMsg(block, msg);
|
||||
}
|
||||
|
||||
if (special_prong == .@"else") {
|
||||
if (special_prong == .@"else" and seen_errors.count() == operand_ty.errorSetNames().len) {
|
||||
return sema.fail(
|
||||
block,
|
||||
special_prong_src,
|
||||
|
||||
@ -610,14 +610,11 @@ test "switch on pointer type" {
|
||||
}
|
||||
|
||||
test "switch on error set with single else" {
|
||||
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest() !void {
|
||||
var some: error{Foo} = error.Foo;
|
||||
try expect(switch (some) {
|
||||
else => |a| blk: {
|
||||
a catch {};
|
||||
else => blk: {
|
||||
break :blk true;
|
||||
},
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user