diff --git a/src/Sema.zig b/src/Sema.zig index 341cb1c85523..9f103121bb3b 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -11875,8 +11875,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, diff --git a/test/behavior/switch.zig b/test/behavior/switch.zig index b5540664c947..3e50853a8f66 100644 --- a/test/behavior/switch.zig +++ b/test/behavior/switch.zig @@ -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 ({}) { + {} => {}, + } +}