[Issue 22978] Shared destructor is not able change immutable var but shared constructor can

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Mar 23 21:54:16 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=22978

Nick Treleaven <nick at geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick at geany.org

--- Comment #1 from Nick Treleaven <nick at geany.org> ---
`x.o` is immutable. It is by design that `x` itself can be initialized in a
shared static constructor. Initializing `x.o` directly is also OK (so long as
it is not reassigned, that is not currently enforced though, but it is for a
class constructor with immutable fields).

It is correct that the destructor can't mutate immutable data.

--


More information about the Digitalmars-d-bugs mailing list