From d6161e7e9ea1f40ad734c6e811e8169fe24b5e9f Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sat, 1 Aug 2020 22:03:15 +0200 Subject: [PATCH] fixes #15129 [backport:1.2] (#15144) --- compiler/sempass2.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index 6db6448df..41d83ed55 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -843,7 +843,7 @@ proc track(tracked: PEffects, n: PNode) = if n.sym.typ != nil and tfHasAsgn in n.sym.typ.flags: tracked.owner.flags.incl sfInjectDestructors # bug #15038: ensure consistency - if not hasDestructor(n.typ): n.typ = n.sym.typ + if not hasDestructor(n.typ) and sameType(n.typ, n.sym.typ): n.typ = n.sym.typ of nkHiddenAddr, nkAddr: if n[0].kind == nkSym and isLocalVar(tracked, n[0].sym): useVarNoInitCheck(tracked, n[0], n[0].sym)