www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22978] New: Shared destructor is not able change immutable

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 puremagic.com
          Reporter: apz28 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`
}

--
Apr 03 2022