Files
Nim/tests/destructor/tdestructor2.nim
2014-01-13 02:10:03 +01:00

22 lines
358 B
Nim

discard """
line: 20
errormsg: " usage of a type with a destructor in a non destructible context"
"""
type
TMyObj = object
x, y: int
p: pointer
proc destruct(o: var TMyObj) {.destructor.} =
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()