Comment #0 by bearophile_hugs — 2012-12-18T18:36:00Z
This program compiles with no errors:
struct Foo {
static immutable F = Foo();
static immutable Foo[] foos1 = [F];
}
void main() {}
If I remove the type of foos1 it doesn't compile:
struct Foo {
static immutable F = Foo();
static immutable foos1 = [F];
}
void main() {}
DMD 2.061alpha gives:
test.d(3): Error: forward reference of variable F
Comment #1 by b2.temp — 2019-04-04T10:34:33Z
Funnily this alternative, which still needs inference for the array, works
---
struct Foo {
static immutable foos1 = [F];
static immutable F = Foo();
}
---
Because type semantic of `F` is launched when doing the one of `foo1`, hence `F` is not already "inuse".
Comment #2 by robert.schadek — 2024-12-13T18:03:28Z