tcast.nim 338 B

123456789101112131415
  1. # Make sure we don't walk cast[T] type section while injecting sinks/destructors
  2. block:
  3. type
  4. XY[T] = object
  5. discard
  6. proc `=`[T](x: var XY[T]; v: XY[T]) {.error.}
  7. proc `=sink`[T](x: var XY[T]; v: XY[T]) {.error.}
  8. proc main[T]() =
  9. var m = cast[ptr XY[T]](alloc0(sizeof(XY[T])))
  10. doAssert(m != nil)
  11. main[int]()