digitalmars.D.bugs - [Issue 21332] New: Circular reference to a static field of a struct
- d-bugmail puremagic.com (44/44) Oct 19 2020 https://issues.dlang.org/show_bug.cgi?id=21332
https://issues.dlang.org/show_bug.cgi?id=21332 Issue ID: 21332 Summary: Circular reference to a static field of a struct for inferred types Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: lsferreira169 gmail.com On this code: ```d immutable _a = S.c; struct S { immutable a = _a; static immutable c = "bar"; } ``` _a only depends on S.c which is "bar", so this should work, because logically, this is the same as: ```d immutable _a = _c; private immutable _c = "bar"; struct S { immutable a = _a; static immutable c = _c; } ``` The problem here seems to be the type inference on `immutable a`, because this code works fine: ```d immutable _a = S.c; struct S { immutable string a = _a; static immutable c = "bar"; } ``` In the worst case, this should give a more clear message like: "Can't infer type of variable `a`" --
Oct 19 2020