From 30921aaff52d34f0a5286db70229db087666bfdf Mon Sep 17 00:00:00 2001 From: SirOlaf <34164198+SirOlaf@users.noreply.github.com> Date: Sat, 22 Jul 2023 21:13:55 +0200 Subject: [PATCH] Check try block for endsInNoReturn (#22314) Co-authored-by: SirOlaf <> (cherry picked from commit 62869a5c68e4dd91e00ee77b039f0175482ef4fa) --- compiler/semstmts.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 7711bfce5b..1f0c630f41 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -229,8 +229,8 @@ proc semTry(c: PContext, n: PNode; flags: TExprFlags; expectedType: PType = nil) var typ = commonTypeBegin var expectedType = expectedType n[0] = semExprBranchScope(c, n[0], expectedType) - typ = commonType(c, typ, n[0].typ) if not endsInNoReturn(n[0]): + typ = commonType(c, typ, n[0].typ) expectedType = typ var last = n.len - 1 @@ -306,7 +306,8 @@ proc semTry(c: PContext, n: PNode; flags: TExprFlags; expectedType: PType = nil) result.typ = c.enforceVoidContext else: if n.lastSon.kind == nkFinally: discardCheck(c, n.lastSon.lastSon, flags) - n[0] = fitNode(c, typ, n[0], n[0].info) + if not endsInNoReturn(n[0]): + n[0] = fitNode(c, typ, n[0], n[0].info) for i in 1..last: var it = n[i] let j = it.len-1