Hi!

Consider this simplified program:
```
import std.stdio;

struct X {
    void method(int x) {
        writeln("method called");
    }
}


void main() {
    X x;

    foreach (member; __traits(allMembers, X)) {
        alias method = __traits(getMember, x, member);
        method(1);
    }
}
```

Output:
test.d(15): Error: need this for method of type void(int x)



This one as well:
```
import std.stdio;

struct X {
    void method(int x) {
        writeln("method(int) called");
    }
}


struct Y {
    void method(ref X x) {
        foreach (member; __traits(allMembers, X)) {
            alias method = __traits(getMember, x, member);
            method(1);
        }
    }
}


void main() {
    Y y;
    X x;
    y.method(x);
}
```

Output:
```test.d(14): Error: this for method needs to be type X not type Y```


This is a bug, right? If not, why, and how can I get around it and call `method`?

Reply via email to