[Issue 23278] New: Can't pass alias member to a function
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jul 31 23:44:12 UTC 2022
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 at puremagic.com
Reporter: msnmancini at 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.
--
More information about the Digitalmars-d-bugs
mailing list