bugfix: finally sections are executed before return/break
This commit is contained in:
parent
0a57f662fa
commit
ea2306b301
6 changed files with 64 additions and 2 deletions
12
tests/accept/run/mmultim3.nim
Normal file
12
tests/accept/run/mmultim3.nim
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
type
|
||||||
|
TObj* = object
|
||||||
|
|
||||||
|
var myObj* : ref TObj
|
||||||
|
|
||||||
|
method test123(a : ref TObj) =
|
||||||
|
echo("Hi base!")
|
||||||
|
|
||||||
|
proc testMyObj*() =
|
||||||
|
test123(myObj)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -16,6 +16,7 @@ tcgbug.nim;
|
||||||
tclosure.nim;2 4 6 8 10
|
tclosure.nim;2 4 6 8 10
|
||||||
tcnstseq.nim;AngelikaAnneAnnaAnkaAnja
|
tcnstseq.nim;AngelikaAnneAnnaAnkaAnja
|
||||||
tconstr2.nim;69
|
tconstr2.nim;69
|
||||||
|
tcontinuexc.nim;ECcaught
|
||||||
tcopy.nim;TEMP=C:\Programs\xyz\bin
|
tcopy.nim;TEMP=C:\Programs\xyz\bin
|
||||||
tcurrncy.nim;25
|
tcurrncy.nim;25
|
||||||
texplicitgeneric1.nim;Key: 12 value: 12Key: 13 value: 13 Key: A value: 12 Key: B value: 13
|
texplicitgeneric1.nim;Key: 12 value: 12Key: 13 value: 13 Key: A value: 12 Key: B value: 13
|
||||||
|
|
|
||||||
|
|
|
@ -13,9 +13,11 @@ try:
|
||||||
try:
|
try:
|
||||||
genErrors("error!")
|
genErrors("error!")
|
||||||
except ESomething:
|
except ESomething:
|
||||||
echo("Error happened")
|
stdout.write("E")
|
||||||
echo "came here"
|
stdout.write("C")
|
||||||
raise newException(EsomeotherErr, "bla")
|
raise newException(EsomeotherErr, "bla")
|
||||||
finally:
|
finally:
|
||||||
echo "caught"
|
echo "caught"
|
||||||
|
|
||||||
|
#OUT ECcaught
|
||||||
|
|
||||||
|
|
|
||||||
21
tests/accept/run/tfinally2.nim
Normal file
21
tests/accept/run/tfinally2.nim
Normal 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
|
||||||
|
|
||||||
12
tests/accept/run/tfinally3.nim
Normal file
12
tests/accept/run/tfinally3.nim
Normal 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
|
||||||
|
|
||||||
14
tests/accept/run/tmultim3.nim
Normal file
14
tests/accept/run/tmultim3.nim
Normal 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()
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue