template gRandBoolean*(rand: expr): expr =
((gRandInt(rand) and (1 shl 15)) != 0)
echo "compiles fine, while gRandInt() does not exist"
The code above with the c2nim generated template compiles fine while the proc gRandInt() is not visible. So as long as that template is not really used that problem is hidden.
Is there a way to automatically detect that?
In the long term we may try to convert such types of templates to procs which makes problems visible. But the ten gtk related wrappers have a few hundred of such templates, which no one really intends to use. So it would be fine if we can at least ensure that all the symbols in the templates do exist.
The check for this really isn't that feasible. Remember that templates are evaluated where they are called, and part of that evaluation is symbol binding.
For such a mechanism to work well, the compiler would have to check every possible expression, including statement lists.