summary refs log tree commit diff stats
path: root/tests/arc
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2024-08-11 16:12:48 +0800
committerGitHub <noreply@github.com>2024-08-11 10:12:48 +0200
commit1d59e1cbb6521d1c5c9a634dbd6bcbcbc8ae1cd4 (patch)
tree62a9dc8d613fc00f44436573aa2b0764323b0815 /tests/arc
parent2a2474d395afb58ef71897530ff334f4725514b4 (diff)
downloadNim-1d59e1cbb6521d1c5c9a634dbd6bcbcbc8ae1cd4.tar.gz
fixes #23907; Double destroy using proc type alias with a sink (#23909)
fixes #23907
Diffstat (limited to 'tests/arc')
-rw-r--r--tests/arc/tarcmisc.nim23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/arc/tarcmisc.nim b/tests/arc/tarcmisc.nim
index 88582303d..58b4aa7c0 100644
--- a/tests/arc/tarcmisc.nim
+++ b/tests/arc/tarcmisc.nim
@@ -766,3 +766,26 @@ block: # bug #23524
     doAssert t2.a == 100
 
   main()
+
+block: # bug #23907
+  type
+    Thingy = object
+      value: int
+
+    ExecProc[C] = proc(value: sink C): int {.nimcall.}
+
+  proc `=copy`(a: var Thingy, b: Thingy) {.error.}
+
+  var thingyDestroyCount = 0
+
+  proc `=destroy`(thingy: Thingy) =
+    assert(thingyDestroyCount <= 0)
+    thingyDestroyCount += 1
+
+  proc store(value: sink Thingy): int =
+    result = value.value
+
+  let callback: ExecProc[Thingy] = store
+
+  doAssert callback(Thingy(value: 123)) == 123
+