Some testing?
    Don 
    nospam at nospam.com
       
    Wed Jul 14 13:26:31 PDT 2010
    
    
  
bearophile wrote:
> This small D2 program compiles with no errors:
> 
> T foo(T)(T x) {}
> void main() {}
> 
> But there is no way it can compile, regardless of the type T, because foo()() lacks a return statement. 
> So is it possible for the D compiler to perform some sanity tests for the template functions too, to catch a bugs like this one?
> 
> Bye,
> bearophile
Yes, it'd be possible for such simple cases, but would it be worthwhile?
Since an error message will occur for ANY instantiation of foo, the only 
errors that would catch are when there's absolutely no testing or use of 
foo. In which case you have much bigger problems.
And unfortunately it doesn't scale to more complex situations where it 
might actually help.
    
    
More information about the Digitalmars-d-learn
mailing list