diff --git a/compiler/transf.nim b/compiler/transf.nim index f0cf9dd33b3bb..2e3a493492bf3 100644 --- a/compiler/transf.nim +++ b/compiler/transf.nim @@ -1348,25 +1348,108 @@ proc flattenStmts(n: PNode) = goOn = true inc i +proc isEmptyStmt(n: PNode): bool = + case n.kind + of nkEmpty: + result = true + of nkStmtList, nkStmtListExpr: + result = n.len == 0 + of nkWhen: + result = true + for branch in n: + if not isEmptyStmt(branch[^1]): + return false + else: + result = false + +proc copyBranchWithBody(n, body: PNode; typ: PType): PNode = + result = shallowCopy(n) + result.typ = typ + for i in 0..