This is bug or not? (immutable class containing struct with dtor)

Denis Feklushkin feklushkin.denis at gmail.com
Fri Dec 17 18:32:43 UTC 2021


On Friday, 17 December 2021 at 18:02:52 UTC, Tejas wrote:

I improved your sample:

```d
immutable struct S
{
     ~this() {}
}

immutable struct S2
{
     S sss;
     ~this() {}
}

void main()
{
     S2 s = S2();
}
```

```
Error: `immutable` method `serializer_bug.S.~this` is not 
callable using a mutable object
Error: mutable method `serializer_bug.S2.~this` is not callable 
using a `immutable` object
serializer_bug.d(17,5):        Consider adding `const` or `inout` 
here
```

immutable dtor can't be called at all?



More information about the Digitalmars-d-learn mailing list