January 24, 2023
https://issues.dlang.org/show_bug.cgi?id=23652

          Issue ID: 23652
           Summary: Valid code rejected with a "circular reference" error
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: maxsamukha@gmail.com

struct DTB
{
    enum staticOverhead = DispatchTable!().sizeof;
}

struct DispatchTable()
{
    static assert (DTB.staticOverhead == typeof(this).sizeof);
}

Error: circular reference to variable `sc.tree.core.DTB.staticOverhead`


But the non-templated version compiles successfully:

struct DTB
{
    enum staticOverhead = DispatchTable.sizeof;
}

struct DispatchTable
{
    static assert (DTB.staticOverhead == typeof(this).sizeof);
}

--