www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2010] New: Template tuples don't work in string mixins

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

           Summary: Template tuples don't work in string mixins
           Product: D
           Version: 2.012
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: bartosz relisoft.com


A variable-argument function works at runtime, but doesn't compile as a mixin:

mixin (declareAllFeatures ("a", "b", "c"));

string declareAllFeatures (T...)(T features)
{
        string [] arr = [];
        foreach (f; features)
        {
                arr ~= f;
        }
        return declareAllFeaturesArr (arr);
}

string declareAllFeaturesArr (string [] allFeatures)
{
        return "int x;";
}


-- 
Apr 18 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2010






The order of declarations seems to matter, so here's the modified example and
the error message:

string declareAllFeaturesArr (string [] allFeatures)
{
    return "int x;";
}

string declareAllFeatures (T...)(T features)
{
    string [] arr = [];
    foreach (f; features)
    {
            arr ~= f;
    }
    return declareAllFeaturesArr (arr);
}

mixin (declareAllFeatures ("a", "b", "c"));

Error: cannot evaluate declareAllFeatures(&"a",&"b",&"c") at compile time


-- 
Apr 18 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2010


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug yahoo.com.au
         Resolution|                            |FIXED



This was fixed before 2.022.

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