--gc:destructors: simple closures work

This commit is contained in:
Andreas Rumpf 2019-11-02 00:39:04 +01:00
commit 44a27ccfe1
4 changed files with 20 additions and 13 deletions

View file

@ -1275,6 +1275,8 @@ proc genTypeInfo2Name(m: BModule; t: PType): Rope =
it = it.sons[0]
result = makeCString(res)
proc trivialDestructor(s: PSym): bool {.inline.} = s.ast[bodyPos].len == 0
proc genObjectInfoV2(m: BModule, t, origType: PType, name: Rope; info: TLineInfo) =
assert t.kind == tyObject
if incompleteType(t):
@ -1282,7 +1284,7 @@ proc genObjectInfoV2(m: BModule, t, origType: PType, name: Rope; info: TLineInfo
typeToString(t))
var d: Rope
if t.destructor != nil:
if t.destructor != nil and not trivialDestructor(t.destructor):
# the prototype of a destructor is ``=destroy(x: var T)`` and that of a
# finalizer is: ``proc (x: ref T) {.nimcall.}``. We need to check the calling
# convention at least: