From afd4e22f76bc2234ea660a110376839d726770f7 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Sat, 5 Nov 2022 22:47:12 +0800 Subject: [PATCH] Revert "fix arc global variable issues" (#20764) * Revert "fix arc global variable issues (#20759)" This reverts commit a3d32a4176539d0829a4e868f4b005a1a71eb7ee. * trigger documentation builds --- .github/workflows/ci_docs.yml | 1 + compiler/injectdestructors.nim | 7 ++----- tests/arc/tarcmisc.nim | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci_docs.yml b/.github/workflows/ci_docs.yml index 6228c48c81..cde30e5fa8 100644 --- a/.github/workflows/ci_docs.yml +++ b/.github/workflows/ci_docs.yml @@ -14,6 +14,7 @@ on: - 'tools/kochdocs.nim' - '.github/workflows/ci_docs.yml' - 'koch.nim' + pull_request: # Run only on changes on these files. paths: diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim index eda73eeb53..ad43e23fcc 100644 --- a/compiler/injectdestructors.nim +++ b/compiler/injectdestructors.nim @@ -490,11 +490,8 @@ proc pVarTopLevel(v: PNode; c: var Con; s: var Scope; res: PNode) = res.add newTree(nkFastAsgn, v, genDefaultCall(v.typ, c, v.info)) elif sfThread notin v.sym.flags and sfCursor notin v.sym.flags: # do not destroy thread vars for now at all for consistency. - if sfGlobal in v.sym.flags: #XXX: Rethink this logic (see tarcmisc.test2) - if c.inLoop > 0: - s.final.add c.genDestroy(v) - else: - c.graph.globalDestructors.add c.genDestroy(v) + if sfGlobal in v.sym.flags and s.parent == nil: #XXX: Rethink this logic (see tarcmisc.test2) + c.graph.globalDestructors.add c.genDestroy(v) else: s.final.add c.genDestroy(v) diff --git a/tests/arc/tarcmisc.nim b/tests/arc/tarcmisc.nim index 3160d8a4df..567daf9823 100644 --- a/tests/arc/tarcmisc.nim +++ b/tests/arc/tarcmisc.nim @@ -124,7 +124,7 @@ proc test(count: int) = test(3) proc test2(count: int) = - block: #XXX: Fails with block currently + #block: #XXX: Fails with block currently var v {.global.} = newVariable(20) var count = count - 1