www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23128] New: Attributes inference breaks down with cycles


          Issue ID: 23128
           Summary: Attributes inference breaks down with cycles
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: kinke gmx.net

struct S {
    int x;
    int getX()() { return !x ? getY() : x; }
    int getY()() { return !x ? -1 : getX(); }

static assert(__traits(compiles, (S s)  safe => s.getX())); // fails

 safety of getX() depends on getY(), and vice-versa. The compiler currently
simply falls back to  system. It should probably try harder to resolve such
cyclic dependencies.

May 20 2022