Bug 21332 – Circular reference to a static field of a struct for inferred types

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-10-19T17:32:39Z
Last change time
2024-12-13T19:12:15Z
Assigned to
No Owner
Creator
Luís Ferreira
Moved to GitHub: dmd#19809 →

Comments

Comment #0 by contact — 2020-10-19T17:32:39Z
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`"
Comment #1 by contact — 2020-10-19T17:42:29Z
Comment #2 by robert.schadek — 2024-12-13T19:12:15Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19809 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB