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
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.
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.
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