You can use the `{.error.}` pragma with `when` to cause a compilation error,
you can also give a message
template `==`(a: Real, b: typed): bool =
when typeof(b) is not float:
{.error: "Reals can only be compared to floats".}
a.val == b
Run
- Detecting type errors in template at compile time spip
- Re: Detecting type errors in template at compile time TinBryn
