` `=destroy`(x.field.addr[])` is a symptom, not the cause. The cause is you do 
something you shouldn't do. The compiler composes a perfectly fine destructor 
on its own.

Here is when you need a custom destructor: When your type has a `ptr` or 
"handle like" integer type and you want to free the corresponding resource 
automatically so that it composes well with the rest of Nim. Things like 
`string` or `ref` are already handled for you, always.

Let's say you have `graphicsDevice: Handle` in your `ref Graphics` object.

  * Wrong: Override `ref Graphic`'s destructor. (The compiler should catch that 
but maybe it still doesn't.)
  * Right: Put the `graphicsDevice: Handle` in a helper object (NOT A `ref 
object`!) and override `=destroy` for that one.


Reply via email to