Thread overview
[Issue 1461] New: Local variable as template alias parameter breaks CTFE
Aug 31, 2007
d-bugmail
Jun 30, 2008
d-bugmail
Sep 03, 2009
Walter Bright
August 31, 2007
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;
    }
}


-- 

June 30, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1461


clugdbug@yahoo.com.au changed:

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




------- Comment #1 from clugdbug@yahoo.com.au  2008-06-30 03:50 -------
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;
    }
}


-- 

September 03, 2009
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




--- Comment #2 from Walter Bright <bugzilla@digitalmars.com>  2009-09-03 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: -------