From 9ad184841e2ac40dc329bbe70eaa251b8928d457 Mon Sep 17 00:00:00 2001 From: SirOlaf <34164198+SirOlaf@users.noreply.github.com> Date: Sat, 2 Sep 2023 20:42:40 +0200 Subject: [PATCH] Exclude block from endsInNoReturn, fix regression (#22632) Co-authored-by: SirOlaf <> (cherry picked from commit d2f36c071b1967e864961f423596d3931e84e49b) --- compiler/sem.nim | 2 +- tests/exprs/t22604.nim | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/compiler/sem.nim b/compiler/sem.nim index 0be4337287..9fc13d6224 100644 --- a/compiler/sem.nim +++ b/compiler/sem.nim @@ -219,7 +219,7 @@ proc endsInNoReturn(n: PNode): bool = var it = n # skip these beforehand, no special handling needed - while it.kind in {nkStmtList, nkStmtListExpr, nkBlockStmt} and it.len > 0: + while it.kind in {nkStmtList, nkStmtListExpr} and it.len > 0: it = it.lastSon case it.kind diff --git a/tests/exprs/t22604.nim b/tests/exprs/t22604.nim index 570f989d64..c41cd3dfa2 100644 --- a/tests/exprs/t22604.nim +++ b/tests/exprs/t22604.nim @@ -10,19 +10,6 @@ for i in 0..<1: else: raiseAssert "Won't get here" -# block -for i in 0..<1: - let x = - case false - of true: - 42 - of false: - block: - if true: - continue - else: - raiseAssert "Won't get here" - # nested case for i in 0..<1: let x =