diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 8b829cec96b1f..469bbf98ad4b3 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1863,11 +1863,11 @@ proc implicitConv(kind: TNodeKind, f: PType, arg: PNode, m: TCandidate, result = newNodeI(kind, arg.info) if containsGenericType(f): if not m.hasFauxMatch: - result.typ = getInstantiatedType(c, arg, m, f) + result.typ = getInstantiatedType(c, arg, m, f).skipTypes({tySink}) else: result.typ = errorType(c) else: - result.typ = f + result.typ = f.skipTypes({tySink}) if result.typ == nil: internalError(c.graph.config, arg.info, "implicitConv") result.add c.graph.emptyNode result.add arg diff --git a/tests/destructor/tarc.nim b/tests/destructor/tarc.nim index 25921ffd722f7..d5e181630f4e1 100644 --- a/tests/destructor/tarc.nim +++ b/tests/destructor/tarc.nim @@ -100,4 +100,18 @@ mkManyLeaks() tsimpleClosureIterator() tleakingNewStmt() leakObjConstr() + +# bug #12964 + +type + Token* = ref object of RootObj + Li* = ref object of Token + +proc bug12964*() = + var token = Li() + var tokens = @[Token()] + tokens.add token + +bug12964() + echo getOccupiedMem() - startMem