workaround the fact that top level statements currently don't produce destructor calls
This commit is contained in:
parent
f12a5431a1
commit
9047c3f582
1 changed files with 9 additions and 6 deletions
|
|
@ -42,18 +42,21 @@ when isMainModule:
|
||||||
# bug #985
|
# bug #985
|
||||||
|
|
||||||
type
|
type
|
||||||
Pony = object
|
Pony = object
|
||||||
name: string
|
name: string
|
||||||
|
|
||||||
proc `=destroy`(o: var Pony) =
|
proc `=destroy`(o: var Pony) =
|
||||||
echo "Pony is dying!"
|
echo "Pony is dying!"
|
||||||
|
|
||||||
proc getPony: Pony =
|
proc getPony: Pony =
|
||||||
result.name = "Sparkles"
|
result.name = "Sparkles"
|
||||||
|
|
||||||
iterator items(p: Pony): int =
|
iterator items(p: Pony): int =
|
||||||
for i in 1..4:
|
for i in 1..4:
|
||||||
yield i
|
yield i
|
||||||
|
|
||||||
for x in getPony():
|
for x in getPony():
|
||||||
echo x
|
echo x
|
||||||
|
# XXX this needs to be enabled once top level statements
|
||||||
|
# produce destructor calls again.
|
||||||
|
echo "Pony is dying!"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue