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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 3 15:32:04 UTC 2022


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

          Issue ID: 22978
           Summary: Shared destructor is not able change immutable var but
                    shared constructor can
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: apz28 at hotmail.com

struct X
{
    Object o;
}

static immutable X x;

shared static this()
{
    x.o = new Object();
}

shared static ~this()
{
    x.o = null; // onlineapp.d(15): Error: cannot modify `immutable` expression
`x.o`
}

--


More information about the Digitalmars-d-bugs mailing list