[Issue 19786] New: alias to __traits(getMember) wrongfully always binds to this
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Apr 3 12:43:04 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=19786
Issue ID: 19786
Summary: alias to __traits(getMember) wrongfully always binds
to this
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: edi33416 at gmail.com
Give the following code example
```
struct S
{
void foo(const ref S rhs)
{
alias thisMember = __traits(getMember, this, "x");
alias rhsMember = __traits(getMember, rhs, "x");
pragma(msg, thisMember.stringof);
pragma(msg, rhsMember.stringof);
pragma(msg, __traits(getMember, rhs, "x").stringof);
}
int x;
}
```
This outputs
```
this.x
this.x
rhs.x
```
As you can see, `rhsMember.stringof` evaluates to `this.x` instead of `rhs.x`
--
More information about the Digitalmars-d-bugs
mailing list