finding errors with templates without instantiating them

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Sep 11 10:23:10 PDT 2013


On Thu, Sep 05, 2013 at 10:14:01AM -0700, Timothee Cour wrote:
> 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
> }
> ----

This thread has been dormant for a while. Has an enhancement request
been filed yet?


T

-- 
Chance favours the prepared mind. -- Louis Pasteur


More information about the Digitalmars-d mailing list