t22218.nim 524 B

12345678910111213141516171819202122232425
  1. discard """
  2. cmd: "nim c --mm:arc $file"
  3. errormsg: "'=copy' is not available for type <Obj>; requires a copy because it's not the last read of 'chan[]'; routine: test"
  4. """
  5. # bug #22218
  6. type Obj[T] = object
  7. v: T
  8. proc `=copy`[T](
  9. dest: var Obj[T],
  10. source: Obj[T]
  11. ) {.error: "A channel cannot be copied".}
  12. from system/ansi_c import c_calloc
  13. proc test() =
  14. var v: bool = true
  15. var chan = cast[ptr Obj[int]](c_calloc(1, csize_t sizeof(Obj[int])))
  16. var copy = chan[]
  17. echo chan.v
  18. echo v
  19. test()