[Issue 19477] New: Circular alias this makes constructor not work with UFCS only

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 11 13:32:36 UTC 2018


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

          Issue ID: 19477
           Summary: Circular alias this makes constructor not work with
                    UFCS only
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dkorpel at live.nl

I created two types that can convert to eachother:
```
struct Q16 {
    Q32 toQ32() {return Q32.init;}
    alias toQ32 this;
}

struct Q32 {
    this(Q16 a) {}
    Q16 toQ16() {return Q16.init;}
    alias toQ16 this;
}

void main() {
    auto x = Q32(Q16.init);
    auto y = Q16.init.Q32;
}
```

The assignment of x compiles, but for y you get "Error: cannot resolve
identifier Q32". Removing either of the "alias this" makes it work.

--


More information about the Digitalmars-d-bugs mailing list