summary refs log tree commit diff stats
path: root/tests/reject/tdestructor.nim
blob: da9192a3f9a649f2f2eb124bb51528a3f2095999 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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()