Bug 6501 – import inside of eponymous template does not work correctly

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-08-15T20:35:00Z
Last change time
2012-02-14T06:10:57Z
Assigned to
nobody
Creator
issues.dlang

Comments

Comment #0 by issues.dlang — 2011-08-15T20:35:34Z
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
Comment #1 by kennytm — 2011-08-16T06:49:05Z
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.
Comment #2 by issues.dlang — 2011-08-16T10:30:01Z
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.
Comment #3 by code — 2012-02-14T06:10:57Z
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