finding errors with templates without instantiating them

Timothee Cour thelastmammoth at gmail.com
Thu Sep 5 10:14:01 PDT 2013


Currently D will compile templated code that is syntactically correct but
semantically always incorrect (ie regardless of template parameters), eg
the following:
regardless of T, b is not in scope and hence this template cannot be
instantiated without CT error.

So would it be possible to detect such kind of errors (ie CT error
regardless of template params) without having to instantiate the template?
Sure this could be detected with unittests in a perfect world but that
gives an additional level of safety.

Likewise with template constraints, where the code wouldn't be able to
compile given template constraints, but this case is harder.

----
void fun(T)(){
  int a=b;
}

void main(){
  //fun!double; //uncomment for CT error
}
----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130905/927acede/attachment.html>


More information about the Digitalmars-d mailing list