Files
Nim/tests/global/t15005.nim
Bung 95c751a9e4 fix #15005; [ARC] Global variable declared in a block is destroyed too… (#22388)
* fix #15005 [ARC] Global variable declared in a block is destroyed too early
2023-08-06 15:46:43 +08:00

19 lines
215 B
Nim

type
T = ref object
data: string
template foo(): T =
var a15005 {.global.}: T
once:
a15005 = T(data: "hi")
a15005
proc test() =
var b15005 = foo()
doAssert b15005.data == "hi"
test()
test()