Compiler bug..?

davidl davidl at 126.com
Mon Oct 22 23:28:35 PDT 2007


在 Mon, 22 Oct 2007 19:14:54 +0800,Regan Heath <regan at netmail.co.nz> 写道:

> Simen Haugen wrote:
>> static if( 1 ) {
>>     int var;
>> }
>>  static if( 1 ) {
>>     float var; // Error, var already defined. As expected.
>> }
>>   But if we do this....
>>  static if(is(int T == int)) {
>>     writefln("T: ", typeid(T)); // T: int
>> }
>>  static if(is(float T == float)) {
>>     writefln("T: ", typeid(T)); // T: int.... Where's my float?
>> }
>>  Shouldn't this be a compiler error, or at least a warning?
>
> Which version of DMD are you using?
>
> With 2.005 I get an error of "Error: declaration T is already defined"  
> on the 2nd static if line.
>
> Regan

umm, shouldn't T only take effect in the static if scope?
so they shouldn't conflict, and should print float?


-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/



More information about the Digitalmars-d mailing list