www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - static assert fouls up template promotion when between static if

reply Don Clugston <dac nospam.com.au> writes:
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!();
}
Feb 22 2006
next sibling parent Sean Kelly <sean f4.ca> writes:
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
Feb 22 2006
prev sibling next sibling parent Nick <Nick_member pathlink.com> writes:
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
Feb 22 2006
prev sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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 -----BEGIN PGP SIGNATURE----- iD8DBQFD/iCQ3w+/yD4P9tIRAnRSAJ9qx5QvutmlpjFg3Vvh3vJHe1jEyQCfVkxU BI5DyF8FOY89q6VS4GO3w1o= =JTHS -----END PGP SIGNATURE-----
Feb 23 2006