[Issue 23128] New: Attributes inference breaks down with cycles
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Fri May 20 12:35:01 UTC 2022
    
    
  
https://issues.dlang.org/show_bug.cgi?id=23128
          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 at puremagic.com
          Reporter: kinke at 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.
--
    
    
More information about the Digitalmars-d-bugs
mailing list