Comment #0 by andrej.mitrovich — 2011-09-27T17:19:05Z
This will rightly not compile:
struct Foo { int x; }
struct Bar
{
Foo foo;
alias foo.x x;
}
void main()
{
Bar bar;
bar.x = 5;
}
However, if you comment out the "bar.x = 5" line you won't get a compile error. My main problem with this is that I could easily create an invalid alias by accident (due to generic programming) and I won't spot this until I try using an aliased field later down the road. By then I'll end up getting compilation errors which are hard to figure out (due to e.g. multiple aliasing). And yes, that has just happened to me. :)
So I'd like this to be a compilation error regardless if that alias is used or not by client code. As far as I know expression aliases are illegal, unless that changes it would be great if this was enforced right away.
Comment #1 by yebblies — 2011-09-29T19:09:22Z
Basically the complement of issue 4206.
Comment #2 by andrej.mitrovich — 2013-04-13T14:11:59Z
I'd prefer this to actually become a valid feature. This is covered by Issue 6842.