[Issue 24273] Circular reference error flagged in valid code

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 9 17:18:09 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=24273

--- Comment #3 from bmqawsed4 at gmail.com ---
(In reply to anonymous4 from comment #2)
> The problem usually happens as:
> 
> alias int XVar;
> struct Mst
> {
>     XVar XVar;
> }
> 
> As you can see there's an ambiguity who is who.
> Usually it's possible to disambiguate with FQN:
> 
> struct Mst
> {
>     .XVar XVar;
> }
> 
> Stack variables have no FQN, so give them a different name
> 
> alias XVar XVar2;
> struct Mst
> {
>     typeof(XVar2) XVar;
> }

Unfortunately I do not see any ambiguity in my original code.
It _is_ confusing (the situation of the same name being used both in the main
function and the sub-function was an accident, not intentional).
But I cannot see what rule of D has been broken.
To me, if nothing else, D's scope rules should have stopped any problems.

--


More information about the Digitalmars-d-bugs mailing list