new destroyer pass works with procs too

This commit is contained in:
Andreas Rumpf 2017-10-13 07:00:52 +02:00
commit 5dca695bcf
4 changed files with 11 additions and 9 deletions

View file

@ -400,7 +400,7 @@ proc addToVarSection(c: PContext; result: var PNode; orig, identDefs: PNode) =
# in order for this transformation to be correct.
let L = identDefs.len
let value = identDefs[L-1]
if value.typ != nil and tfHasAsgn in value.typ.flags and c.p.owner.kind != skFunc:
if value.typ != nil and tfHasAsgn in value.typ.flags and not newDestructors:
# the spec says we need to rewrite 'var x = T()' to 'var x: T; x = T()':
identDefs.sons[L-1] = emptyNode
if result.kind != nkStmtList: