mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-31 02:12:11 +00:00
bugfix: finally sections are executed before return/break
This commit is contained in:
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
|
||||
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
|
||||
|
||||
|
@@ -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
|
||||
|
||||
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user