Consider:
int[] sneaky;
struct A
{
private int[] innocent;
~this()
{
sneaky = innocent;
}
}
void main()
{
immutable a = A([1, 2, 3]);
{
auto b = a;
}
sneaky[1] = 42; // oops
import std.stdio;
writeln(a.innocent); // ooooops
}
The destructor should not unqualify the structure, or should in limited ways.
Comment #1 by robert.schadek — 2024-12-13T18:58:06Z