On Mon, 26 Aug 2024 at 18:45, Timon Gehr via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
On 8/26/24 07:21, Walter Bright wrote:
> On 8/24/2024 9:36 AM, Manu wrote:
>> alias x = s.tupleof; // this works
>> alias y = s.tupleof[0]; // this is a compile error?!
>
>
> Can you please repost with the missing declarations from your example?
> Thanks!

This suffices to reproduce:

```d
struct S{ int x; }
S s;
alias x = s.tupleof; // this works
alias y = s.tupleof[0]; // this is a compile error?!
```

The underlying issue is that `.tupleof` has some magic that is not
accessible to aliases.

Consider:

```d
struct S{ int x; }
void main(){
     S s;
     alias x = s.tupleof;
     x[0] = 2; // ok
     alias y = s.x;
     y = 2; // error
}
```

So `x[0]` is an alias to the field of an instance.

I think all of these examples should just work.

When template parameters get involved however, local instantiation can
get a bit tricky. So making it work without breakage probably also comes
down to the issue that local instantiation works with only one context,
which had a fix in DMD but was never ported to GDC and LDC, and was then
reverted via deprecation in DMD as well. This is one of the most
annoying and long-standing issues in D.

I endorse every word of this post.