summary refs log blame commit diff stats
path: root/tests/destructor/tdestructor2.nim
blob: 1bdf4993b91bedad96307ae85eb0b139276c9e88 (plain) (tree)
1
2
3
4
5
6
7




                                                                              

                




                 
                                          









                                          
discard """
  line: 20
  errormsg: " usage of a type with a destructor in a non destructible context"
"""

{.experimental.}

type  
  TMyObj = object
    x, y: int
    p: pointer
    
proc destroy(o: var TMyObj) {.override.} =
  if o.p != nil: dealloc o.p
  
proc open: TMyObj =
  result = TMyObj(x: 1, y: 2, p: alloc(3))


proc `$`(x: TMyObj): string = $x.y

echo open()