enum Enum { Foo, Bar } void test(Enum en)() if(0) { } void main() { test!(Enum.Bar)(); } test.d(11): Error: template instance test!(cast(Enum)1) test!(cast(Enum)1) does not match template declaration test(Enum en) if (0) test.d(11): Error: function expected before (), not test!(cast(Enum)1) of type void This is really awful because when you have over a few dozen fields in an enum you end up having to count the fields to figure out which enum value was actually used when instantiating the template. (Either that or having to insert a to!string call just for debugging). The above errors should be: test.d(11): Error: template instance test!(Enum.Bar) test!(Enum.Bar) does not match template declaration test(Enum en) if (0) test.d(11): Error: function expected before (), not test!(Enum.Bar) of type void
See also Issue 5004
Related problem: import std.stdio; enum Foo { A, B } const Foo f = Foo.A; enum Bar : ubyte { C, D } const Bar b = Bar.C; void main() { pragma(msg, f, " ", b); writeln(f, " ", b); } Output: cast(Foo)0 cast(Bar)cast(ubyte)0u A C Expected output: A C A C
@Geod24 created dlang/dmd pull request #11841 "Fix 8044 - Print name of enum passed a tmpl param" fixing this issue: - Fix 8044 - Print name of enum passed a tmpl param https://github.com/dlang/dmd/pull/11841
*** Issue 14067 has been marked as a duplicate of this issue. ***
*** Issue 18479 has been marked as a duplicate of this issue. ***
dlang/dmd pull request #11841 "Fix 8044 - Print name of enum passed a tmpl param" was merged into master: - 05bf5a11d82676f56751e3e69482df6c22c33a31 by Geod24: Fix 8044 - Print name of enum passed a tmpl param https://github.com/dlang/dmd/pull/11841