[Issue 21332] New: Circular reference to a static field of a struct for inferred types
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Oct 19 17:32:39 UTC 2020
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 at puremagic.com
Reporter: lsferreira169 at 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`"
--
More information about the Digitalmars-d-bugs
mailing list