is(this == bug) ???

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Apr 1 17:40:27 PDT 2009


dsimcha wrote:
> == Quote from dsimcha (dsimcha at yahoo.com)'s article
>> void doStuff(T)(T arg)
>> if(is(typeof(arg))) {
>> }
>> void main() {
>>     doStuff(1);
>> }
>> Results:
>> test7.d|6|template test7.doStuff(T) if (is(typeof(arg))) does not match any
>> function template declaration|
>> test7.d|6|template test7.doStuff(T) if (is(typeof(arg))) cannot deduce
>> template function from argument types !()(int)|
>> This code does not compile with 2.027, 2.026, or 2.016 (the first version that
>> had constraints).  If it is, in fact, a bug, I find it amazing that it's
>> apparently taken over half a year for anyone to notice.  (Searching bugzilla
>> for "constraints" yields nothing.)  If it's not a bug, then I can't for the
>> life of me figure out why it won't compile.
> 
> (Slapping forehead)
> 
> Never mind.  After struggling with this for an hour, I realized that arg is not in
> scope when the constraint is evaluated.

No, no, always mind. The parameter name should be visible in the 
if-constraint of a template. Please file a bug.

Also the parameter names should be visible in the return type (if it 
uses e.g. sizeof or typeof). I think I filed that.


Andrei



More information about the Digitalmars-d mailing list