bugfix: finally sections are executed before return/break

This commit is contained in:
Araq
2010-09-20 23:54:40 +02:00
parent 0a57f662fa
commit ea2306b301
6 changed files with 64 additions and 2 deletions

View File

@@ -0,0 +1,12 @@
type
TObj* = object
var myObj* : ref TObj
method test123(a : ref TObj) =
echo("Hi base!")
proc testMyObj*() =
test123(myObj)

View File

@@ -16,6 +16,7 @@ tcgbug.nim;
tclosure.nim;2 4 6 8 10
tcnstseq.nim;AngelikaAnneAnnaAnkaAnja
tconstr2.nim;69
tcontinuexc.nim;ECcaught
tcopy.nim;TEMP=C:\Programs\xyz\bin
tcurrncy.nim;25
texplicitgeneric1.nim;Key: 12 value: 12Key: 13 value: 13 Key: A value: 12 Key: B value: 13
1 tack.nim 125
16 tclosure.nim 2 4 6 8 10
17 tcnstseq.nim AngelikaAnneAnnaAnkaAnja
18 tconstr2.nim 69
19 tcontinuexc.nim ECcaught
20 tcopy.nim TEMP=C:\Programs\xyz\bin
21 tcurrncy.nim 25
22 texplicitgeneric1.nim Key: 12 value: 12Key: 13 value: 13 Key: A value: 12 Key: B value: 13

View File

@@ -13,9 +13,11 @@ try:
try:
genErrors("error!")
except ESomething:
echo("Error happened")
echo "came here"
stdout.write("E")
stdout.write("C")
raise newException(EsomeotherErr, "bla")
finally:
echo "caught"
#OUT ECcaught

View File

@@ -0,0 +1,21 @@
# Test break in try statement:
proc main: int =
try:
block AB:
try:
try:
break AB
finally:
stdout.write("A")
stdout.write("skipped")
finally:
block B:
stdout.write("B")
stdout.write("skipped")
stdout.write("C")
finally:
stdout.writeln("D")
discard main() #OUT ABCD

View File

@@ -0,0 +1,12 @@
# Test break in try statement:
proc main: bool =
while true:
try:
return true
finally:
break
return false
echo main() #OUT false

View File

@@ -0,0 +1,14 @@
import mmultim3
type
TBObj* = object of TObj
method test123(a : ref TBObj) =
echo("Hi derived!")
var a : ref TBObj
new(a)
myObj = a
testMyObj()