digitalmars.D.bugs - [Issue 23278] New: Can't pass alias member to a function
- d-bugmail puremagic.com (41/41) Jul 31 2022 https://issues.dlang.org/show_bug.cgi?id=23278
https://issues.dlang.org/show_bug.cgi?id=23278 Issue ID: 23278 Summary: Can't pass alias member to a function Product: D Version: D2 Hardware: All OS: Windows Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: msnmancini hotmail.com This trivial code fails to compile with the error message: `onlineapp.Test2.mxString!(oops).mxString` need `this` to access member `mxString` ```d class Test2 { string oops; mixin(mxString!(oops)); } enum mxString(alias c)() { return ""; } ``` This should compile as there is no dependent usage on "this". Plus, the message is obviously wrong as there is no member named `mxString`. A real use case for that is: ```d enum mxString(alias c)() { return typeof(c).stringof~" "~c.stringof~c.stringof~";"; } ``` Which does not depends on "this", as some code like `mxString!(typeof(oops), oops.stringof)` would work. Mixin template does not have this limitation, so, I believe a normal function should not too. --
Jul 31 2022