diff options
author | Bung <crc32@qq.com> | 2023-08-06 15:46:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-06 15:46:43 +0800 |
commit | 95c751a9e4d42eb61917684339406d1ff07a4225 (patch) | |
tree | 53c01ddde433b1ba58fbd70beb76c7a9e0296015 /tests/global | |
parent | 137d608d7d68a91c99149aa1127dd675ee45f751 (diff) | |
download | Nim-95c751a9e4d42eb61917684339406d1ff07a4225.tar.gz |
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
Diffstat (limited to 'tests/global')
-rw-r--r-- | tests/global/t15005.nim | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/global/t15005.nim b/tests/global/t15005.nim new file mode 100644 index 000000000..6395b1dde --- /dev/null +++ b/tests/global/t15005.nim @@ -0,0 +1,18 @@ +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() |