diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2024-08-11 16:12:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-11 10:12:48 +0200 |
commit | 1d59e1cbb6521d1c5c9a634dbd6bcbcbc8ae1cd4 (patch) | |
tree | 62a9dc8d613fc00f44436573aa2b0764323b0815 /tests/arc | |
parent | 2a2474d395afb58ef71897530ff334f4725514b4 (diff) | |
download | Nim-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.nim | 23 |
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 + |