digitalmars.D - Compiler bug..?
- Simen Haugen (14/14) Oct 22 2007 static if( 1 ) {
- Regan Heath (5/25) Oct 22 2007 Which version of DMD are you using?
- Simen Haugen (3/6) Oct 22 2007 1.022
- Regan Heath (6/14) Oct 22 2007 In that case it looks like a bug fix which made it into 2.0 and not 1.0.
- davidl (5/24) Oct 22 2007 umm, shouldn't T only take effect in the static if scope?
- Simen Haugen (3/28) Oct 23 2007 No, static if's doesn't introduce a new scope.
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?
Oct 22 2007
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
Oct 22 2007
"Regan Heath" <regan netmail.co.nz> wrote in message news:ffi0ne$vb1$2 digitalmars.com...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.1.022
Oct 22 2007
Simen Haugen wrote:"Regan Heath" <regan netmail.co.nz> wrote in message news:ffi0ne$vb1$2 digitalmars.com...In that case it looks like a bug fix which made it into 2.0 and not 1.0. I would search bugzilla and see if there is a bug report for this (presumably closed) and re-open it or whatever is appropriate (I'm not sure what bugzilla netiquette applies here) ReganWhich 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.1.022
Oct 22 2007
在 Mon, 22 Oct 2007 19:14:54 +0800,Regan Heath <regan netmail.co.nz> 写道:Simen Haugen wrote: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/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
Oct 22 2007
"davidl" <davidl 126.com> wrote in message news:op.t0mz9xh9eb62bo 9568023b6e5d4f4__aad...? Mon, 22 Oct 2007 19:14:54 +0800,Regan Heath <regan netmail.co.nz> ??:No, static if's doesn't introduce a new scope.Simen Haugen wrote:umm, shouldn't T only take effect in the static if scope? so they shouldn't conflict, and should print float?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
Oct 23 2007