Skip to content

Commit

Permalink
fix finally noreturn logic
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn committed Jun 4, 2024
1 parent 5eb99e7 commit b71bd1b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions compiler/semstmts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,15 @@ proc endsInNoReturn(n: PNode, returningNode: var PNode): bool =
result = hasElse
of nkTryStmt:
checkBranch(it[0])
for i in 1 ..< it.len:
var lastIndex = it.len - 1
if it[lastIndex].kind == nkFinally:
# if finally is noreturn, then the entire statement is noreturn
if endsInNoReturn(it[lastIndex][^1], returningNode):
return true
dec lastIndex
for i in 1 .. lastIndex:
let branch = it[i]
if branch.kind != nkFinally:
checkBranch(branch[^1])
checkBranch(branch[^1])
# none of the branches returned
result = true
of nkLastBlockStmts:
Expand Down

0 comments on commit b71bd1b

Please sign in to comment.