destructors now work with overloaded assignment operators; fixes #2811; fixes #1632

This commit is contained in:
Araq 2015-08-05 21:27:53 +02:00
commit 0d8942d45e
7 changed files with 175 additions and 15 deletions

View file

@ -1,6 +1,10 @@
discard """
output: '''hi
hi'''
hi
1
hi
B
A'''
"""
# bug #1742
@ -16,3 +20,23 @@ import strutils
let x = try: parseInt("133a")
except: -1
finally: echo "hi"
template atFuncEnd =
defer:
echo "A"
defer:
echo "B"
template testB(): expr =
let a = 0
defer: echo "hi" # Delete this line to make it work
a
proc main =
atFuncEnd()
echo 1
let i = testB()
echo 2
main()