Bug 23153 – Immutable variables should undergo same flow analysis in module constructors as in regular constructors

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-06-01T20:22:06Z
Last change time
2024-12-13T19:23:13Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
Iain Buclaw
Moved to GitHub: dmd#20115 →

Comments

Comment #0 by ibuclaw — 2022-06-01T20:22:06Z
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); } } ```
Comment #1 by robert.schadek — 2024-12-13T19:23:13Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20115 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB