bugfix: proc bodies as expr

This commit is contained in:
Araq 2012-09-23 09:02:11 +02:00
commit 83b90b941b

View file

@ -1075,8 +1075,11 @@ proc semProcBody(c: PContext, n: PNode): PNode =
if c.p.resultSym != nil and not isEmptyType(result.typ): if c.p.resultSym != nil and not isEmptyType(result.typ):
# transform ``expr`` to ``result = expr``, but not if the expr is already # transform ``expr`` to ``result = expr``, but not if the expr is already
# ``result``: # ``result``:
if result.kind == nkSym and result.sym == c.p.resultSym: if result.kind == nkSym and result.sym == c.p.resultSym:
nil nil
elif result.kind == nkNilLit:
# ambiguous :-(
result.typ = nil
else: else:
var a = newNodeI(nkAsgn, n.info, 2) var a = newNodeI(nkAsgn, n.info, 2)
a.sons[0] = newSymNode(c.p.resultSym) a.sons[0] = newSymNode(c.p.resultSym)