This commit is contained in:
Araq 2014-03-28 08:40:15 +01:00
commit 12e3c11eb6
3 changed files with 7 additions and 1 deletions

View file

@ -1038,6 +1038,7 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
return return
else: else:
s = n[namePos].sym s = n[namePos].sym
s.owner = getCurrOwner()
typeIsDetermined = s.typ == nil typeIsDetermined = s.typ == nil
s.ast = n s.ast = n
s.scope = c.currentScope s.scope = c.currentScope
@ -1165,6 +1166,11 @@ proc semIterator(c: PContext, n: PNode): PNode =
let kind = if hasPragma(n[pragmasPos], wClosure) or let kind = if hasPragma(n[pragmasPos], wClosure) or
n[namePos].kind == nkEmpty: skClosureIterator n[namePos].kind == nkEmpty: skClosureIterator
else: skIterator else: skIterator
# gensym'ed iterator?
if n[namePos].kind == nkSym:
# gensym'ed iterators might need to become closure iterators:
n[namePos].sym.owner = getCurrOwner()
n[namePos].sym.kind = kind
result = semProcAux(c, n, kind, iteratorPragmas) result = semProcAux(c, n, kind, iteratorPragmas)
var s = result.sons[namePos].sym var s = result.sons[namePos].sym
var t = s.typ var t = s.typ

View file

@ -28,6 +28,7 @@ macro async2(prc: stmt): stmt {.immediate.} =
# -> iterator nameIter(): PFutureBase {.closure.} = <proc_body> # -> iterator nameIter(): PFutureBase {.closure.} = <proc_body>
# Changing this line to: newIdentNode($prc[0].ident & "Iter") # will make it work. # Changing this line to: newIdentNode($prc[0].ident & "Iter") # will make it work.
var iteratorNameSym = genSym(nskIterator, $prc[0].ident & "Iter") var iteratorNameSym = genSym(nskIterator, $prc[0].ident & "Iter")
#var iteratorNameSym = newIdentNode($prc[0].ident & "Iter")
var procBody = prc[6].convertReturns(retFutureSym) var procBody = prc[6].convertReturns(retFutureSym)
var closureIterator = newProc(iteratorNameSym, [newIdentNode("PFutureBase")], var closureIterator = newProc(iteratorNameSym, [newIdentNode("PFutureBase")],

View file

@ -1,7 +1,6 @@
version 0.9.4 version 0.9.4
============= =============
- fix gensym capture bug
- fix GC issues - fix GC issues
Bugs Bugs