www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23144] New: False circular reference error when the field

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

          Issue ID: 23144
           Summary: False circular reference error when the field name of
                    a struct or class is the same as the type name
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: menodinulla gmail.com

False circular reference error occurs when the field name of a struct or class
is the same as the type name of the field.
This error doesn't occur on local variables.

---
module example;

struct S { }

struct OtherStruct
{
    S s; // allowed
    S S; // Error: circular reference to variable `example.OtherStruct.S`
}

class C { }

class OtherClass
{
    C c; // allowed
    C C; // Error: circular reference to variable `example.OtherClass.C`
}

int main()
{
    S S; // allowed
    C C; // allowed
    return 0;
}

--
May 28 2022