summary refs log blame commit diff stats
path: root/tests/destructor/tcast.nim
blob: 35a7d874b559884e58051f886d0c4adcbec85518 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14













                                                                                
# Make sure we don't walk cast[T] type section while injecting sinks/destructors
block:
  type
    XY[T] = object
      discard

  proc `=`[T](x: var XY[T]; v: XY[T]) {.error.}
  proc `=sink`[T](x: var XY[T]; v: XY[T]) {.error.}

  proc main[T]() =
    var m = cast[ptr XY[T]](alloc0(sizeof(XY[T])))
    doAssert(m != nil)

  main[int]()