This commit is contained in:
Ryan Mehri 2025-11-23 22:56:58 +00:00 committed by GitHub
commit 9b8bda29fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View file

@ -11909,8 +11909,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
}
}
},
.enum_literal, .void, .@"fn", .pointer, .type => {
if (!has_else) {
.enum_literal, .void, .@"fn", .pointer, .type => |tag| {
if (!has_else and tag != .void) {
return sema.fail(
block,
src,

View file

@ -1120,3 +1120,9 @@ test "switch on non-exhaustive enum" {
try E.doTheTest(.a);
try comptime E.doTheTest(.a);
}
test "switch on void without else prong" {
switch ({}) {
{} => {},
}
}