summary refs log tree commit diff stats
path: root/compiler/semexprs.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/semexprs.nim')
-rw-r--r--compiler/semexprs.nim12
1 files changed, 7 insertions, 5 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 5e61c4a0b..f9889eee1 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -1317,18 +1317,20 @@ proc semYield(c: PContext, n: PNode): PNode =
   elif n.sons[0].kind != nkEmpty:
     n.sons[0] = semExprWithType(c, n.sons[0]) # check for type compatibility:
     var iterType = c.p.owner.typ
-    var restype = iterType.sons[0]
+    let restype = iterType.sons[0]
     if restype != nil:
-      let adjustedRes = if c.p.owner.kind == skIterator: restype.base
+      let adjustedRes = if restype.kind == tyIter: restype.base
                         else: restype
-      n.sons[0] = fitNode(c, adjustedRes, n.sons[0])
+      if adjustedRes.kind != tyExpr:
+        n.sons[0] = fitNode(c, adjustedRes, n.sons[0])
       if n.sons[0].typ == nil: internalError(n.info, "semYield")
       
       if resultTypeIsInferrable(adjustedRes):
         let inferred = n.sons[0].typ
-        if c.p.owner.kind == skIterator:
-          iterType.sons[0].sons[0] = inferred
+        if restype.kind == tyIter:
+          restype.sons[0] = inferred
         else:
+          debug inferred
           iterType.sons[0] = inferred
       
       semYieldVarResult(c, n, adjustedRes)