On Monday, 7 January 2013 at 07:58:29 UTC, Walter Bright wrote:
A huge source of fwd ref problems was not at all about symbol
lookup. It was about partial types referencing properties of
themselves. For example,
struct S {
int a;
int b = S.sizeof;
int c;
}
for a simple example. There've been all kinds of variations on
this theme, some of them wickedly complicated, but always
boiling down to the same general issue.
Some forward ref regressions have cropped up because the
compiler now does a better job of checking if there is enough
of the type computed to get the desired property. Formerly, it
would just return an incorrect size (for example). (I do not
know if this is the case for your example, yet.)
I've had certain headaches from that as well trying to make my
polymorphic struct, it's easy to see how it can get lost.
struct S {
static struct Data {
int i;
}
union {
Data data;
S2 s2; //problem line
}
}
struct S2 {
S base; //problem line
}
Here the whole size is defined by Data, however because S2
references S1 before it has a concrete size it can get stuck (may
still get stuck, not sure).
Hmmm in cases like this, a @size attribute could be useful
(forces it to believe given size rather than looking it up). So
that could become:
union {
Data data;
@size(Data.sizeof) S2 s2; //size hint, forward ref problem
gone
}