Thread overview
[Issue 6501] New: import inside of eponymous template does not work correctly
Aug 16, 2011
Jonathan M Davis
Aug 16, 2011
kennytm@gmail.com
Aug 16, 2011
Jonathan M Davis
Feb 14, 2012
dawg@dawgfoto.de
August 16, 2011
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


--- Comment #0 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-08-15 20:35:34 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: -------
August 16, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6501


kennytm@gmail.com changed:

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


--- Comment #1 from kennytm@gmail.com 2011-08-16 06:49:05 PDT ---
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: -------
August 16, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6501



--- Comment #2 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-08-16 10:30:01 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: -------
February 14, 2012
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


--- Comment #3 from dawg@dawgfoto.de 2012-02-14 06:10:57 PST ---
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: -------