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).

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


-- 
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




------- Comment #1 from bugzilla digitalmars.com  2006-11-30 03:25 -------
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                  |




------- Comment #2 from clugdbug yahoo.com.au  2006-11-30 04:02 -------
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




------- Comment #3 from clugdbug yahoo.com.au  2007-07-02 04:46 -------
This now works in 1.018. It was probably fixed in 1.012 when bug#532 was fixed.


-- 
Jul 02 2007