Skip to content

Commit 548b1c6

Browse files
authored
fixes #25369 (#25370)
fixes #25369
1 parent 9bb57a6 commit 548b1c6

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

compiler/injectdestructors.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ proc p(n: PNode; c: var Con; s: var Scope; mode: ProcessMode; tmpFlags = {sfSing
969969
isInProc
970970

971971
if isGlobalPragma:
972-
c.graph.procGlobals.add n
972+
c.graph.procGlobals.add newTree(nkFastAsgn, v, ri)
973973
else:
974974
let value = moveOrCopy(v, ri, c, s, if v.kind == nkSym: {IsDecl} else: {})
975975
result.add value

tests/global/mglobal3.nim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
proc v*() =
2+
let u {.global.} = default(ref int)

tests/global/tglobal3.nim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,7 @@ proc m2() =
6262
assert v == "123"
6363

6464
m2()
65+
66+
import mglobal3
67+
block:
68+
v()

0 commit comments

Comments
 (0)