summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2014-03-06 23:03:02 +0200
committerZahary Karadjov <zahary@gmail.com>2014-03-06 23:03:02 +0200
commit249dd7027302c913513cf577beed83512236fc57 (patch)
tree527fd7921e51c8efa5fc079d7eefea42e9ed27ef /compiler
parent862c0ef83d7a85798df0474522dd4ba8cfcab674 (diff)
downloadNim-249dd7027302c913513cf577beed83512236fc57.tar.gz
test cases for the new handling of iterators by the `is` operator
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semexprs.nim5
-rw-r--r--compiler/sigmatch.nim12
2 files changed, 9 insertions, 8 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index ebdd79a8c..203a51816 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -323,11 +323,6 @@ proc isOpImpl(c: PContext, n: PNode): PNode =
       result = newIntNode(nkIntLit, ord(t.kind == tyProc and
                                         t.callConv == ccClosure and 
                                         tfIterator notin t.flags))
-    of "iterator":
-      let t = skipTypes(t1, abstractRange)
-      result = newIntNode(nkIntLit, ord(t.kind == tyProc and
-                                        t.callConv == ccClosure and 
-                                        tfIterator in t.flags))
   else:
     var t2 = n[2].typ.skipTypes({tyTypeDesc})
     let lifted = liftParamType(c, skType, newNodeI(nkArgList, n.info),
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index 6a3c9267e..c0898ef26 100644
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -410,7 +410,10 @@ proc procTypeRel(c: var TCandidate, f, a: PType): TTypeRelation =
         return isNone
     when useEffectSystem:
       if not compatibleEffects(f, a): return isNone
-  of tyNil: result = f.allowsNil
+  of tyNil:
+    result = f.allowsNil
+  of tyIter:
+    if tfIterator in f.flags: result = typeRel(c, f.base, a.base)
   else: discard
 
 proc typeRangeRel(f, a: PType): TTypeRelation {.noinline.} =
@@ -923,8 +926,11 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
         result = isNone
  
   of tyIter:
-    if a.kind == f.kind: result = typeRel(c, f.base, a.base)
-    else: result = isNone
+    if a.kind == tyIter or 
+      (a.kind == tyProc and tfIterator in a.flags):
+      result = typeRel(c, f.base, a.base)
+    else:
+      result = isNone
 
   of tyStmt:
     result = isGeneric