zig
zig copied to clipboard
error: else prong required when switching on type 'void'
Zig Version
0.16.0-dev.747+493ad58ff
Steps to Reproduce and Observed Behavior
pub fn main() !void {
switch({}) {
{} => {},
}
}
zig run a.zig
a.zig:2:5: error: else prong required when switching on type 'void'
switch({}) {
^~~~~~
Expected Behavior
There should be no error because all cases are handled
But why switch on type void in the first place ? Wouldn't it be better to use an enum with no fields ?
an enum with no fields is uninstantiable. but i do agree that without a clearer use case explanation switching on void should be a compile error outright.