mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 18:02:05 +00:00
28 lines
415 B
Nim
28 lines
415 B
Nim
discard """
|
|
line: 23
|
|
nimout: " 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) =
|
|
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
|
|
|
|
proc foo =
|
|
discard open()
|
|
|
|
# XXX doesn't trigger this yet:
|
|
#echo open()
|
|
|