How to check two function type matches?

/// return true if
/// a = b; // a: Afunc, b: Bfunc
/// won’t cause a compile error
fn match_function_type(Afunc: type, Bfunc: type) bool

simply Afunc == Bfunc is not all the cases.

by the way, is there a way to capture the compile error?

1 Like

You can check if the functions have the same function pointer type:
@TypeOf(&a) == @TypeOf(&b)

2 Likes

is there a way to capture the compile error?

What do you mean by “capture” here?

FWIW stuff like this will work and lets the compiler check for you:

fn callBoth(funcA: anytype, funcB: @TypeOf(funcA)) ...
2 Likes