Comptime-dependent switch prongs

I’d like to build a tree-walker that’s customized at compile time, e.g.

pub const WalkAction = enum { map, filter };

pub fn exprWalker(T: type, E: type, comptime action: WalkAction) type {
    return struct {
        alloc: Allocator,
        context: T,
        walker: Walker,

        pub const Result = switch (action) {
            .map => union(enum) {
                ignore: void,
                replace: Expr,
            },
            .filter => union(enum) {
                ignore: void,
                discard: void,
                replace: Expr,
            },
        };
...

The number of enum elements and switch prongs varies depending on the value of action. Is it possible to make a switch arm optional?

const rhs = switch (right) {
    .ignore => binary.rhs.*,
    .replace => |x| x,
    if (action == .filter) .discard => .discard,
};

The above doesn’t work because, it seems, I need to supply the value of the tag for the else clause

error: expected type '@typeInfo(ir.exprWalker(ir_gen.expandMacro.Context,error{...).Result__union_25571).@"union".tag_type.?', found 'void'
                        if (action == .filter) .discard => .discard,