Properly wrap discarded statements (#10322)
Failing to do so lead the codegen to emit invalid code sometimes, especially when C++ references were involved. Fixes #10241
This commit is contained in:
parent
52a54f5f04
commit
15584879b9
3 changed files with 35 additions and 12 deletions
|
|
@ -917,7 +917,7 @@ proc semExprNoType(c: PContext, n: PNode): PNode =
|
|||
let isPush = hintExtendedContext in c.config.notes
|
||||
if isPush: pushInfoContext(c.config, n.info)
|
||||
result = semExpr(c, n, {efWantStmt})
|
||||
discardCheck(c, result, {})
|
||||
result = discardCheck(c, result, {})
|
||||
if isPush: popInfoContext(c.config)
|
||||
|
||||
proc isTypeExpr(n: PNode): bool =
|
||||
|
|
@ -1639,7 +1639,7 @@ proc semProcBody(c: PContext, n: PNode): PNode =
|
|||
a.sons[1] = result
|
||||
result = semAsgn(c, a)
|
||||
else:
|
||||
discardCheck(c, result, {})
|
||||
result = discardCheck(c, result, {})
|
||||
|
||||
if c.p.owner.kind notin {skMacro, skTemplate} and
|
||||
c.p.resultSym != nil and c.p.resultSym.typ.isMetaType:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue