With my current code I keep on getting typeDesc and type instead of both of
them being types. How do I fix this specific issue or is there already a better
implementation?
macro typecheck*(arg: typed, typ: typed) =
## Type check a proc name with args to types
let argType = arg.getType.repr # Syms won't be the same for some reason
let typType = typ.repr # Syms won't be the same for some reason
if not (argType == typType and arg.getType.typeKind ==
typ.getType.typeKind):
let message = "type mismatch\nExpected: '" & typType & "' got '" &
argType & "'"
return quote do:
block:
{.error: `message`.}
return arg
Run
Calls:
echo typecheck(a, int)
Run