I have an enum where some of the fields are available only in safe mode:
const std = @import("std");
const E = if (std.debug.runtime_safety)
enum { a, b, c, d }
else
enum { a, c };
fn f(comptime e: E) void {
switch (e) {
.a => {},
.c => {},
else => if (std.debug.runtime_safety)
switch (e) {
.b => {},
.d => {},
},
}
}
pub fn main() void {
_ = f(.a);
}
Trying to compile the above code in non-safe builds yields an error
src\main.zig:12:14: error: unreachable else prong; all cases already handled
else => if (std.debug.runtime_safety)
Which options do I have? Defining all enum values regardless of the build mode is not a good idea, since those are also used to automatically construct VTables and there would be entries which should not be there, leading to instantiations of safe mode-only handlers (which I'd like to prevent).