diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index d650ab3d09..3436ea0396 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -2410,9 +2410,12 @@ proc semStmtList(c: PContext, n: PNode, flags: TExprFlags, expectedType: PType = else: n.typ = n[i].typ if not isEmptyType(n.typ): n.transitionSonsKind(nkStmtListExpr) - if n[i].kind in nkLastBlockStmts or - n[i].kind in nkCallKinds and n[i][0].kind == nkSym and - sfNoReturn in n[i][0].sym.flags: + var m = n[i] + while m.kind in {nkStmtListExpr, nkStmtList} and m.len > 0: # from templates + m = m.lastSon + if m.kind in nkLastBlockStmts or + m.kind in nkCallKinds and m[0].kind == nkSym and + sfNoReturn in m[0].sym.flags: for j in i + 1..