diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2024-01-19 04:47:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-18 21:47:13 +0100 |
commit | b2f79df81cc1fb2cfd4566ffa868043e286eba5c (patch) | |
tree | c9328fe4cdcc5bc4a33db09d3ada4393fae7aaee /tests/arc | |
parent | 3fb46fac32b8a1fcf36ac52d09983297251d1213 (diff) | |
download | Nim-b2f79df81cc1fb2cfd4566ffa868043e286eba5c.tar.gz |
fixes #22218; avoids cursor when copy is disabled (#23209)
fixes #22218
Diffstat (limited to 'tests/arc')
-rw-r--r-- | tests/arc/t22218.nim | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/arc/t22218.nim b/tests/arc/t22218.nim new file mode 100644 index 000000000..7837ed1d0 --- /dev/null +++ b/tests/arc/t22218.nim @@ -0,0 +1,25 @@ +discard """ + cmd: "nim c --mm:arc $file" + errormsg: "'=copy' is not available for type <Obj>; requires a copy because it's not the last read of 'chan[]'; routine: test" +""" + +# bug #22218 +type Obj[T] = object + v: T + +proc `=copy`[T]( + dest: var Obj[T], + source: Obj[T] + ) {.error: "A channel cannot be copied".} + +from system/ansi_c import c_calloc + +proc test() = + var v: bool = true + var chan = cast[ptr Obj[int]](c_calloc(1, csize_t sizeof(Obj[int]))) + var copy = chan[] + + echo chan.v + echo v + +test() \ No newline at end of file |