digitalmars.D.bugs - [Issue 10708] New: Class members as template alias parameters not CTFE-able
- d-bugmail puremagic.com (38/38) Jul 23 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10708
- d-bugmail puremagic.com (11/11) Jul 25 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10708
http://d.puremagic.com/issues/show_bug.cgi?id=10708 Summary: Class members as template alias parameters not CTFE-able Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: johannespfau gmail.com PDT --- Test case: ------------------------ class TestClass { int a; this() { enum c = getAttribute!(TestClass.a); } } int getAttribute(alias target)() { return 0; } ------------------------ produces this error in DMD 2.063: Error: value of 'this' is not known at compile time This is annoying as you can use e.g. __traits(getAttributes, TestClass.a) but you can not wrap this call into a template because of this bug. A workaround as mentioned by Andrej Mitrovic is adding static to the getAttribute template declaration. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 23 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10708 This isn't actually a CTFE issue. Something weird is happening here, maybe related to UFCS. The declaration of c is actually being transformed into: enum c = this.getAttribute!(TestClass.a); and that's the 'this' which CTFE is complaining about. Bizarrely, marking the template as 'static' prevents that incorrect 'this' from being added. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 25 2013