Thread overview
static assert fouls up template promotion when between static if statements.
Feb 22, 2006
Don Clugston
Feb 22, 2006
Sean Kelly
Re: static assert fouls up template promotion when between static if
Feb 23, 2006
Nick
Feb 24, 2006
Thomas Kuehne
February 22, 2006
If you uncomment the indicated line, it won't compile.
(The fact that the others will compile is a really nice feature from DMD 0.146).
Note that a failed template promotion can easily send the compiler into an error message orgy, which you unfortunately can't break out of with ^C.

template cat()
{
    static assert(1);  // OK
    static if (1) {
//       static assert(1); // doesn't work
       static if (1) {
            static assert(1);  // OK
            const int cat = 3;
       }
    }
}

void main() {
 const int a = cat!();
}
February 22, 2006
Don Clugston wrote:
> If you uncomment the indicated line, it won't compile.
> (The fact that the others will compile is a really nice feature from DMD 0.146).

They will?  Awesome!  I hadn't checked this recently.


Sean
February 23, 2006
In article <dthlsr$1t9a$1@digitaldaemon.com>, Don Clugston says...
>
>Note that a failed template promotion can easily send the compiler into an error message orgy, which you unfortunately can't break out of with ^C.

If you're on linux, try compiling with eg. "make | head".

Sorta OT, but I think the error message orgy itself should be treated as a bug. If the compiler fails to instantiate a template, it continues to compile the entire program but fails with _every_ template. This leads to tons of unrelated and bogus error messages like "template instance cannot resolve forward reference".

Nick


February 24, 2006
Don Clugston schrieb am 2006-02-22:
> If you uncomment the indicated line, it won't compile.
> (The fact that the others will compile is a really nice feature from DMD
> 0.146).
> Note that a failed template promotion can easily send the compiler into
> an error message orgy, which you unfortunately can't break out of with ^C.
>
> template cat()
> {
>      static assert(1);  // OK
>      static if (1) {
> //       static assert(1); // doesn't work
>         static if (1) {
>              static assert(1);  // OK
>              const int cat = 3;
>         }
>      }
> }
>
> void main() {
>   const int a = cat!();
> }

Added to DStress as http://dstress.kuehne.cn/compile/a/assert_14_A.d http://dstress.kuehne.cn/nocompile/a/assert_14_B.d http://dstress.kuehne.cn/nocompile/a/assert_14_C.d http://dstress.kuehne.cn/compile/a/assert_14_D.d http://dstress.kuehne.cn/compile/a/assert_14_E.d http://dstress.kuehne.cn/nocompile/a/assert_14_F.d http://dstress.kuehne.cn/compile/a/assert_14_G.d http://dstress.kuehne.cn/nocompile/a/assert_14_H.d http://dstress.kuehne.cn/nocompile/a/assert_14_I.d http://dstress.kuehne.cn/compile/a/assert_14_J.d

Thomas