summary refs log tree commit diff stats
path: root/tests/refc
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2024-06-07 09:01:30 +0200
committerGitHub <noreply@github.com>2024-06-07 09:01:30 +0200
commit7039b8b5bc5c62cdd608a769e0ea556e23973cc5 (patch)
treefa4e644892846e1d333f9b9311efe1bb1efd2a12 /tests/refc
parent8f5ae28fab113c425d22e5abc230f456fa627744 (diff)
downloadNim-7039b8b5bc5c62cdd608a769e0ea556e23973cc5.tar.gz
fixes #23354; [backport] (#23685)
Diffstat (limited to 'tests/refc')
-rw-r--r--tests/refc/tsinkbug.nim17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/refc/tsinkbug.nim b/tests/refc/tsinkbug.nim
new file mode 100644
index 000000000..2cd762f40
--- /dev/null
+++ b/tests/refc/tsinkbug.nim
@@ -0,0 +1,17 @@
+discard """
+  matrix: "--gc:refc; --gc:arc"
+  output: '''
+Value is: 42
+Value is: 42'''
+"""
+
+type AnObject* = object of RootObj
+  value*: int
+
+proc mutate(a: sink AnObject) =
+  a.value = 1
+
+var obj = AnObject(value: 42)
+echo "Value is: ", obj.value
+mutate(obj)
+echo "Value is: ", obj.value