<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 26 Aug 2024 at 18:45, Timon Gehr via Digitalmars-d <<a href="mailto:digitalmars-d@puremagic.com">digitalmars-d@puremagic.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 8/26/24 07:21, Walter Bright wrote:<br>
> On 8/24/2024 9:36 AM, Manu wrote:<br>
>> alias x = s.tupleof; // this works<br>
>> alias y = s.tupleof[0]; // this is a compile error?!<br>
> <br>
> <br>
> Can you please repost with the missing declarations from your example? <br>
> Thanks!<br>
<br>
This suffices to reproduce:<br>
<br>
```d<br>
struct S{ int x; }<br>
S s;<br>
alias x = s.tupleof; // this works<br>
alias y = s.tupleof[0]; // this is a compile error?!<br>
```<br>
<br>
The underlying issue is that `.tupleof` has some magic that is not <br>
accessible to aliases.<br>
<br>
Consider:<br>
<br>
```d<br>
struct S{ int x; }<br>
void main(){<br>
S s;<br>
alias x = s.tupleof;<br>
x[0] = 2; // ok<br>
alias y = s.x;<br>
y = 2; // error<br>
}<br>
```<br>
<br>
So `x[0]` is an alias to the field of an instance.<br>
<br>
I think all of these examples should just work.<br>
<br>
When template parameters get involved however, local instantiation can <br>
get a bit tricky. So making it work without breakage probably also comes <br>
down to the issue that local instantiation works with only one context, <br>
which had a fix in DMD but was never ported to GDC and LDC, and was then <br>
reverted via deprecation in DMD as well. This is one of the most <br>
annoying and long-standing issues in D.<br></blockquote><div><br></div><div>I endorse every word of this post.</div></div></div>