Compiling the following code gives me:
Error: unable to determine fields of `Foo` because of forward references
import std.container: Array;
struct Foo { Array!Bar _barA; }
struct Bar { Frop _frop; }
class Frop { Array!Foo _foos; }
Comment #1 by b2.temp — 2020-06-13T10:46:58Z
Somewhat reduced:
---
import std.traits;
struct Array(T)
{
static if (hasIndirections!T) {}
}
struct Foo { Array!Bar _barA; }
struct Bar { Frop _frop; }
class Frop { Array!Foo _foos; }
---
The problem is caused by the call to `hasIndirections` and to a nested call to `isDynamicArray`.
changing the `isDynamiArray` implementation from:
enum bool isDynamicArray(T) = is(DynamicArrayTypeOf!T) && !isAggregateType!T;
to
enum isDynamicArray(T) = !isAggregateType!T && is(DynamicArrayTypeOf!T);
allows to compile without error but without really fixing the root of the problem, which seems to reside in `DynamicArrayTypeOf`.
Comment #2 by dlang-bot — 2023-01-16T01:26:07Z
@ibuclaw created dlang/dmd pull request #14826 "dmd.aggregate: Define importAll override for AggregateDeclaration" fixing this issue:
- fix Issue 20913 - Array "forward reference" error
https://github.com/dlang/dmd/pull/14826
Comment #3 by robert.schadek — 2024-12-01T16:36:54Z