diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/injectdestructors.nim | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim index 6b3fdeca5..a278f7c49 100644 --- a/compiler/injectdestructors.nim +++ b/compiler/injectdestructors.nim @@ -857,7 +857,9 @@ proc p(n: PNode; c: var Con; s: var Scope; mode: ProcessMode; tmpFlags = {sfSing result[i][1] = p(n[i][1], c, s, m) else: result[i] = p(n[i], c, s, m) - if mode == normal and isRefConstr: + if mode == normal and (isRefConstr or (hasDestructor(c, t) and + getAttachedOp(c.graph, t, attachedDestructor) != nil and + sfOverridden in getAttachedOp(c.graph, t, attachedDestructor).flags)): result = ensureDestruction(result, n, c, s) of nkCallKinds: if n[0].kind == nkSym and n[0].sym.magic == mEnsureMove: |