mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
Merge 94d9264a90 into 9082b004b6
This commit is contained in:
commit
9b8bda29fc
2 changed files with 8 additions and 2 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 ({}) {
|
||||
{} => {},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue