On Friday, 17 December 2021 at 17:34:05 UTC, Denis Feklushkin wrote:
On Friday, 17 December 2021 at 17:27:53 UTC, Denis Feklushkin wrote:

~this() {} // Comment out this to fix this compilation error:
    // Error: `immutable` method `serializer_bug.Imm.~this` is

("serializer_bug" is just name of my local .d file)

I think since `immutable` objects are kept in Read Only Storage, you can't call destructors on them since the objects don't get erased when `~this` is called, but rather they get assigned their `.init` value, which tells the GC that they can be collected.

`immutable class` has nothing to do with it, even the following fails to compile:
```d



struct S
{
    ~this() immutable {}
}

void main()
{
    S s = S();
}

Error: `immutable` method `onlineapp.S.~this` is not callable using a mutable object
```

Reply via email to