[Issue 23153] New: Immutable variables should undergo same flow analysis in module constructors as in regular constructors
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jun 1 20:22:06 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23153
Issue ID: 23153
Summary: Immutable variables should undergo same flow analysis
in module constructors as in regular constructors
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: ibuclaw at gdcproject.org
i.e: This compiles:
```
immutable int x;
immutable int* y;
shared static this()
{
y = &x;
assert(*y == 0);
x = 42;
assert(*y == 42);
}
```
But the expected behaviour is to fail compilation, same as:
```
struct S
{
immutable int x;
this(int n)
{
auto y = &x;
assert(*y == 0);
x = n;
assert(*y == n);
}
}
```
--
More information about the Digitalmars-d-bugs
mailing list