I'm using Nim type system and templates to build a table of allowed types in a
DSL language, like the following:
template final_sort2(v: bool): typedesc =
AST_bool
template final_sort2(v: int): typedesc =
AST_int
...
template final_sort2(v: typed): typedesc =
{.line: instantiationInfo().}:
raise newException(Exception, "Incompatible type: " & $v)
Run
How can I have the compiler raise the exception when the last template is
selected?
The code works without that last template, but the error message and the stack
trace reported by the compiler does not help the developer understand the
reason of the problem.
Error: in expression 'final_sort(b)(ite`gensym19185006)': identifier
expected, but found 'final_sort(b)'
Run
I would rather have a specific message reported when I can.