www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1461] New: Local variable as template alias parameter breaks CTFE

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1461

           Summary: Local variable as template alias parameter breaks CTFE
           Product: D
           Version: 2.003
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: reiner.pope gmail.com


The following code fails to compile with error, "cannot evaluate generate() at
compile time." This error is stopped by declaring x in global scope.

void main()
{
    int x;
    const string text = Gen!(x).generate();
}

template Gen(alias A)
{
    string generate()
    {
        return null;
    }
}


-- 
Aug 31 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1461


clugdbug yahoo.com.au changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|2.003                       |1.019





Changed version, since this applied to D1.x as well. Still not fixed in D1.031.
For phobos2, the code now needs to use 'enum' instead of const to trigger the
behaviour:
---
void main()
{
    int x;
    enum string text = Gen!(x).generate();
}

template Gen(alias A)
{
    string generate()
    {
        return null;
    }
}


-- 
Jun 30 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1461


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED





13:22:35 PDT ---
Fixed dmd 1.047 and 2.032

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 03 2009