mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-01 09:31:18 +00:00
Fixed issue 391 (nested break in except-stmts)
This commit is contained in:
45
tests/exception/texceptionbreak.nim
Normal file
45
tests/exception/texceptionbreak.nim
Normal file
@@ -0,0 +1,45 @@
|
||||
discard """
|
||||
file: "tnestedbreak.nim"
|
||||
output: "1\n2\n3\n4"
|
||||
"""
|
||||
|
||||
# First variety
|
||||
try:
|
||||
raise newException(EOS, "Problem")
|
||||
except EOS:
|
||||
for y in [1, 2, 3]:
|
||||
discard
|
||||
try:
|
||||
discard
|
||||
except EOS:
|
||||
discard
|
||||
echo "1"
|
||||
|
||||
# Second Variety
|
||||
try:
|
||||
raise newException(EOS, "Problem")
|
||||
except EOS:
|
||||
for y in [1, 2, 3]:
|
||||
discard
|
||||
for y in [1, 2, 3]:
|
||||
discard
|
||||
|
||||
echo "2"
|
||||
|
||||
# Third Variety
|
||||
try:
|
||||
raise newException(EOS, "Problem")
|
||||
except EOS:
|
||||
block:
|
||||
break
|
||||
|
||||
echo "3"
|
||||
|
||||
# Fourth Variety
|
||||
block:
|
||||
try:
|
||||
raise newException(EOS, "Problem")
|
||||
except EOS:
|
||||
break
|
||||
|
||||
echo "4"
|
||||
Reference in New Issue
Block a user