diff --git a/compiler/liftdestructors.nim b/compiler/liftdestructors.nim index 64dc3ad45c2ca..3671f62b8eb49 100644 --- a/compiler/liftdestructors.nim +++ b/compiler/liftdestructors.nim @@ -846,7 +846,6 @@ proc isEmptyContainer(g: ModuleGraph, t: PType): bool = (t.kind == tyArray and lengthOrd(g.config, t[0]) == 0) or (t.kind == tySequence and t[0].kind == tyError) - proc createTypeBoundOps(g: ModuleGraph; c: PContext; orig: PType; info: TLineInfo) = ## In the semantic pass this is called in strategic places ## to ensure we lift assignment, destructors and moves properly. diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index 042cd9a6e2840..82287c67584bd 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -906,16 +906,26 @@ proc track(tracked: PEffects, n: PNode) = of nkTypeSection, nkProcDef, nkConverterDef, nkMethodDef, nkIteratorDef, nkMacroDef, nkTemplateDef, nkLambda, nkDo, nkFuncDef: discard - of nkCast, nkHiddenStdConv, nkHiddenSubConv, nkConv: + of nkCast: if n.len == 2: track(tracked, n[1]) if tracked.owner.kind != skMacro: createTypeBoundOps(tracked, n.typ, n.info) + of nkHiddenStdConv, nkHiddenSubConv, nkConv: + if n.len == 2: + track(tracked, n[1]) + if tracked.owner.kind != skMacro: + createTypeBoundOps(tracked, n.typ, n.info) + # This is a hacky solution in order to fix bug #13110. Hopefully + # a better solution will come up eventually. + if n[1].typ.kind != tyString: + createTypeBoundOps(tracked, n[1].typ, n[1].info) of nkObjUpConv, nkObjDownConv, nkChckRange, nkChckRangeF, nkChckRange64: if n.len == 1: track(tracked, n[0]) if tracked.owner.kind != skMacro: createTypeBoundOps(tracked, n.typ, n.info) + createTypeBoundOps(tracked, n[0].typ, n[0].info) of nkBracket: for i in 0..