[Issue 23144] False circular reference error when the field name of a struct or class is the same as the type name
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun May 29 04:11:53 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23144
Basile-z <b2.temp at gmx.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |b2.temp at gmx.com
--- Comment #1 from Basile-z <b2.temp at gmx.com> ---
The message is not wrong: a lookup for `S` in `OtherStruct` begins in the
`OtherStruct` scope so it finds `S` as a member, which is not ready yet.
The module scope operator should be used here or a fully qualified type.
```
struct S { }
struct OtherStruct
{
.S s;
.S S;
}
```
For local variables that works without qualifier because out of order
declarations are not supported and the lookup is only valid for everything that
is declared before the variable S (and then in the parent scopes)
```
int main()
{
S S;
return 0;
}
```
I suggest to close a invalid is the explanations are correct.
--
More information about the Digitalmars-d-bugs
mailing list