summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-03-28 08:40:15 +0100
committerAraq <rumpf_a@web.de>2014-03-28 08:40:15 +0100
commit12e3c11eb67c738da564b2cfb8bb690f7e759b23 (patch)
treeb51e810d1a61b608673d2a33f07744b1a749591d
parent23d581d3771658f924c37345738ce58db8a8669e (diff)
downloadNim-12e3c11eb67c738da564b2cfb8bb690f7e759b23.tar.gz
fixes #911
-rw-r--r--compiler/semstmts.nim6
-rw-r--r--tests/macros/tgensym.nim1
-rw-r--r--todo.txt1
3 files changed, 7 insertions, 1 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 2a6e797da..c31a8a06d 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -1038,6 +1038,7 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
       return
   else:
     s = n[namePos].sym
+    s.owner = getCurrOwner()
     typeIsDetermined = s.typ == nil
     s.ast = n
     s.scope = c.currentScope
@@ -1165,6 +1166,11 @@ proc semIterator(c: PContext, n: PNode): PNode =
   let kind = if hasPragma(n[pragmasPos], wClosure) or
                 n[namePos].kind == nkEmpty: skClosureIterator
              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)
   var s = result.sons[namePos].sym
   var t = s.typ
diff --git a/tests/macros/tgensym.nim b/tests/macros/tgensym.nim
index 629a6097e..3f4140ff4 100644
--- a/tests/macros/tgensym.nim
+++ b/tests/macros/tgensym.nim
@@ -28,6 +28,7 @@ macro async2(prc: stmt): stmt {.immediate.} =
   # -> iterator nameIter(): PFutureBase {.closure.} = <proc_body>
   # Changing this line to: newIdentNode($prc[0].ident & "Iter") # will make it work.
   var iteratorNameSym = genSym(nskIterator, $prc[0].ident & "Iter")
+  #var iteratorNameSym = newIdentNode($prc[0].ident & "Iter")
   var procBody = prc[6].convertReturns(retFutureSym)
 
   var closureIterator = newProc(iteratorNameSym, [newIdentNode("PFutureBase")],
diff --git a/todo.txt b/todo.txt
index 7a315545e..0e61a069b 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,7 +1,6 @@
 version 0.9.4
 =============
 
-- fix gensym capture bug
 - fix GC issues
 
 Bugs