diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-03-19 12:57:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-19 12:57:45 +0100 |
commit | 034dad8e321edcf6cf88a2ad93fceafae267cc74 (patch) | |
tree | 5b2a4550d6e2ec0182fc9b8003e25bc75579e9c1 /compiler | |
parent | 1f2042411a5343ad8bbdc8d2b1a75ce4f866a04c (diff) | |
download | Nim-034dad8e321edcf6cf88a2ad93fceafae267cc74.tar.gz |
fixes #13691 (#13694)
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/injectdestructors.nim | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim index 55886540c..dec437427 100644 --- a/compiler/injectdestructors.nim +++ b/compiler/injectdestructors.nim @@ -602,7 +602,10 @@ proc pVarTopLevel(v: PNode; c: var Con; ri, res: PNode) = res.add newTree(nkFastAsgn, v, genDefaultCall(v.typ, c, v.info)) elif sfThread notin v.sym.flags: # do not destroy thread vars for now at all for consistency. - c.destroys.add genDestroy(c, v) + if sfGlobal in v.sym.flags: + c.graph.globalDestructors.add genDestroy(c, v) + else: + c.destroys.add genDestroy(c, v) if ri.kind == nkEmpty and c.inLoop > 0: res.add moveOrCopy(v, genDefaultCall(v.typ, c, v.info), c) elif ri.kind != nkEmpty: @@ -616,7 +619,7 @@ proc pVarScoped(v: PNode; c: var Con; ri, res: PNode) = # unpacked tuple needs reset at every loop iteration res.add newTree(nkFastAsgn, v, genDefaultCall(v.typ, c, v.info)) elif {sfGlobal, sfThread} * v.sym.flags == {sfGlobal}: - c.destroys.add genDestroy(c, v) + c.graph.globalDestructors.add genDestroy(c, v) else: # We always translate 'var v = f()' into bitcopies. If 'v' is in a loop, # the destruction at the loop end will free the resources. Other assignments |