The error for
```
struct S1 {}
struct S2 { S1 S1; }
```
is
> a7F65CC3F01F0.d:2:16: Error: circular reference to variable `a7F65CC3F01F0.S2.S1`
I believe the right error should be
> a7F65CC3F01F0.d:2:16: Error: variable `a7F65CC3F01F0.S2.S1` is used as a type
A quick verification on run.dlang.io shows that this was the case in the past:
---
Up to 2.062 : Failure with output: Error: unrecognized switch '-main'
2.063 to 2.064 : Failure with output:
-----
onlineapp.d(2): Error: circular reference to 'onlineapp.S2.S1'
onlineapp.d(2): Error: S1 is used as a type
-----
2.065.0: Failure with output: onlineapp.d(2): Error: circular reference to 'onlineapp.S2.S1'
2.066.1 to 2.071.2: Failure with output:
-----
onlineapp.d(2): Error: circular reference to 'onlineapp.S2.S1'
onlineapp.d(2): Error: S1 is used as a type
-----
2.072.2 to 2.078.3: Failure with output: onlineapp.d(2): Error: circular reference to variable 'onlineapp.S2.S1'
Since 2.079.1: Failure with output: onlineapp.d(2): Error: circular reference to variable `onlineapp.S2.S1`
---
but since 2.072.2 among the two messages only the less relevant is output
Comment #1 by razvan.nitu1305 — 2022-06-03T13:22:30Z
I, personally, find that the "is used as a type error" is actually misleading in this context. S1 is a type, the problem is that the variable should have a different name. The "circular reference to variable S1" is also annoying, but I think it's closer to the truth since you are actually creating a circular reference.
Ideally, the error message should be: "variable name S1 conflicts with struct declaration S1". Also, it seems that:
void fun()
{
S1 S1;
}
compiles just fine. Which should not.