July 24, 2013 [Issue 10708] New: Class members as template alias parameters not CTFE-able | ||||
---|---|---|---|---|
| ||||
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 --- Comment #0 from Johannes Pfau <johannespfau@gmail.com> 2013-07-23 23:56:33 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: ------- |
July 25, 2013 [Issue 10708] Class members as template alias parameters not CTFE-able | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johannes Pfau | http://d.puremagic.com/issues/show_bug.cgi?id=10708 --- Comment #1 from Don <clugdbug@yahoo.com.au> 2013-07-25 01:39:22 PDT --- 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: ------- |
Copyright © 1999-2021 by the D Language Foundation