www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6501] New: import inside of eponymous template does not work correctly

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

           Summary: import inside of eponymous template does not work
                    correctly
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: jmdavisProg gmx.com



PDT ---
This code

template eponymous(string str)
{
    import std.metastrings;

    enum eponymous = Format!("%s", str);
}

void main()
{
    pragma(msg, eponymous!("message"));
}

incorrectly prints this during compilation:

eponymous!("message")

whereas if you move the import outside of the template, it correctly prints

message

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 15 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6501


kennytm gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kennytm gmail.com
            Version|unspecified                 |D2



This is because the template has more than one member. Those symbols imported
from std.metastrings can now be accessed from the template, e.g.

--------------
pragma(msg, eponymous!"message".Format);
// prints "template Format(A...)"
pragma(msg, eponymous!"message".eponymous);
// prints "message"
--------------

Perhaps this is by-design.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 16 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6501




PDT ---
Per TDPL, eponymous templates are supposed to be able to have multiple members
(but just one with the same name as the template). So, if that's the issue
here, it's a bug related to not yet fully following TDPL.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 16 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6501


dawg dawgfoto.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |dawg dawgfoto.de
         Resolution|                            |FIXED



cat > a.d << CODE
template eponymous(string str)
{
    import std.metastrings;

    enum eponymous = Format!("%s", str);
}

void main()
{
    pragma(msg, eponymous!("message"));
}
CODE

dmd -c a.d

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 14 2012