fixes #844
This commit is contained in:
parent
4b94aba6de
commit
47e4f9698c
4 changed files with 21 additions and 7 deletions
|
|
@ -1206,7 +1206,7 @@ proc usesResult(n: PNode): bool =
|
|||
for c in n:
|
||||
if usesResult(c): return true
|
||||
|
||||
proc semStmtList(c: PContext, n: PNode): PNode =
|
||||
proc semStmtList(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
# these must be last statements in a block:
|
||||
const
|
||||
LastBlockStmts = {nkRaiseStmt, nkReturnStmt, nkBreakStmt, nkContinueStmt}
|
||||
|
|
@ -1247,12 +1247,14 @@ proc semStmtList(c: PContext, n: PNode): PNode =
|
|||
if n.sons[i].typ == enforceVoidContext or usesResult(n.sons[i]):
|
||||
voidContext = true
|
||||
n.typ = enforceVoidContext
|
||||
if i != last or voidContext or c.inTypeClass > 0:
|
||||
if i == last and efWantValue in flags:
|
||||
n.typ = n.sons[i].typ
|
||||
if not isEmptyType(n.typ): n.kind = nkStmtListExpr
|
||||
elif i != last or voidContext or c.inTypeClass > 0:
|
||||
discardCheck(c, n.sons[i])
|
||||
else:
|
||||
n.typ = n.sons[i].typ
|
||||
if not isEmptyType(n.typ):
|
||||
n.kind = nkStmtListExpr
|
||||
if not isEmptyType(n.typ): n.kind = nkStmtListExpr
|
||||
case n.sons[i].kind
|
||||
of nkVarSection, nkLetSection:
|
||||
let (outer, inner) = insertDestructors(c, n.sons[i])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue