www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
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 digitalmars.com
        ReportedBy: clugdbug 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).



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));
}


-- 
Nov 22 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=584


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME





DMD 0.174 gives:
   test.d(13): Error: circular reference to 'J'
which I believe is correct.


-- 
Nov 30 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=584


clugdbug yahoo.com.au changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |





I get the sensible error message, too, when the filename is four characters
long.
The bug only occurs for me with a filename of three characters.
Please retest this with a filename of three characters.
(eg tes.d).


-- 
Nov 30 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=584


clugdbug yahoo.com.au changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED








-- 
Jul 02 2007