Files
zig/test/cases/compile_errors/switch_expression-non_exhaustive_inline.zig
Justus Klausecker ba549a7d67 Add support for both '_' and 'else' prongs at the same time in switch statements
If both are used, 'else' handles named members and '_' handles
unnamed members. In this case the 'else' prong will be unrolled
to an explicit case containing all remaining named values.
2025-08-07 13:58:47 +02:00

28 lines
383 B
Zig

const E = enum(u8) {
a,
b,
_,
};
export fn f(e: E) void {
switch (e) {
.a => {},
inline _ => {},
}
}
export fn g(e: E) void {
switch (e) {
.a => {},
else => {},
inline _ => {},
}
}
// error
// backend=stage2
// target=native
//
// :10:16: error: cannot inline '_' prong
// :18:16: error: cannot inline '_' prong