digitalmars.D.bugs - [Issue 23153] New: Immutable variables should undergo same flow
- d-bugmail puremagic.com (41/41) Jun 01 2022 https://issues.dlang.org/show_bug.cgi?id=23153
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 puremagic.com Reporter: ibuclaw 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); } } ``` --
Jun 01 2022