[Issue 584] New: Misleading error message "non-constant expression" in tricky template code

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 22 02:38:25 PST 2006


http://d.puremagic.com/issues/show_bug.cgi?id=584

           Summary: Misleading error message "non-constant expression" in
                    tricky template code
           Product: D
           Version: 0.174
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: clugdbug at yahoo.com.au


Like the previous bug I reported, this needs a filename of 3 characters, eg
"bug.d".

In this example, there's a recursive template definition, (which is not
actually called).

It's quite possible that all of these bugs are symptoms of bug#532.

Output:
-----
x
fun.d(17): Error: non-constant expression cast(char[])J!("xxx")
fun.d(17): Error: non-constant expression cast(char[])J!("xxx")

---------
template M(alias F)
{
    enum E { xxxxx }
    alias void function (E) G;
    const char [] H =  typeof(G).mangleof;
}

template J(char [] str)
{
   static if (30==str.length)
        const char [] J =  "x";
   else
        const char [] J = J!("xxx");
}

template K(alias A)
{
   const char [] K = J!(M!(A).H);
}

void main()
{
   int q = 3;
   pragma(msg, K!(q));
}


-- 




More information about the Digitalmars-d-bugs mailing list