mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-24 00:05:25 +00:00
workaround the fact that top level statements currently don't produce destructor calls
This commit is contained in:
@@ -42,18 +42,21 @@ when isMainModule:
|
||||
# bug #985
|
||||
|
||||
type
|
||||
Pony = object
|
||||
name: string
|
||||
Pony = object
|
||||
name: string
|
||||
|
||||
proc `=destroy`(o: var Pony) =
|
||||
echo "Pony is dying!"
|
||||
|
||||
proc getPony: Pony =
|
||||
result.name = "Sparkles"
|
||||
result.name = "Sparkles"
|
||||
|
||||
iterator items(p: Pony): int =
|
||||
for i in 1..4:
|
||||
yield i
|
||||
for i in 1..4:
|
||||
yield i
|
||||
|
||||
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!"
|
||||
|
||||
Reference in New Issue
Block a user