[Issue 24717] alias edge cases with tupleof
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Aug 31 09:41:20 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24717
Nick Treleaven <nick at geany.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|critical |enhancement
--- Comment #4 from Nick Treleaven <nick at geany.org> ---
> alias y = s.tupleof[0]; // this is a compile error?!
The error is:
Error: alias `y` cannot alias an expression `AliasSeq!(s.x)[0]`
That is because an alias declaration cannot target a value.
For:
struct S {
int x;
alias expand=Seq!x;
}
Turns out .tupleof is actually equivalent to the `expand` alias, see:
https://forum.dlang.org/post/vaue5d$1quo$1@digitalmars.com
alias z = AliasSeq!(s.tupleof);
z[0].writeln(); // Error: accessing non-static variable `x` requires an
instance of `S`
So the above error is consistent with the design of symbol aliases. Changing
this issue to an enhancement.
--
More information about the Digitalmars-d-bugs
mailing list