`alias x = v.x;` not working in struct bodies?
Paul Backus
snarwin at gmail.com
Sat Jan 20 15:55:13 UTC 2024
On Saturday, 20 January 2024 at 15:34:59 UTC, Max Samukha wrote:
> Disregard that. I assumed there was 'alias this' in the OP's
> example. Now the question is, should this work:
>
> ```
> struct S
> {
> int x;
> }
>
> struct S2
> {
> S s;
> alias this = s;
> alias x = S.x;
> }
>
> auto x = S2().x; // Error: need 'this'
> ```
> ?
`alias this` is used as a fallback for member lookup when no
symbol with the requested name exists. Since you declared a
symbol named `x` in `S2`, there is no need to fall back to `alias
this` when attempting to look up `S2().x`.
More information about the Digitalmars-d
mailing list