iterators now return tyIter(T);

tyIter(T) represents an "iteration yielding values of type T"

I'm planning to use that in the context of the `is` operator
supporting predicates such as `C.items is iterator` and also
in the upcoming support for higher-order inline iterators.
This commit is contained in:
Zahary Karadjov 2014-03-05 01:14:37 +02:00
commit 5324c9ebba
6 changed files with 18 additions and 11 deletions

View file

@ -845,8 +845,10 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode,
n.sons[0].info)
if lifted != nil: r = lifted
r.flags.incl tfRetType
result.sons[0] = skipIntLit(r)
res.typ = result.sons[0]
r = skipIntLit(r)
if kind == skIterator: r = newTypeWithSons(c, tyIter, @[r])
result.sons[0] = r
res.typ = r
proc semStmtListType(c: PContext, n: PNode, prev: PType): PType =
checkMinSonsLen(n, 1)
@ -959,7 +961,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
of nkTypeOfExpr:
# for ``type(countup(1,3))``, see ``tests/ttoseq``.
checkSonsLen(n, 1)
result = semExprWithType(c, n.sons[0], {efInTypeof}).typ
result = semExprWithType(c, n.sons[0], {efInTypeof}).typ.skipTypes({tyIter})
of nkPar:
if sonsLen(n) == 1: result = semTypeNode(c, n.sons[0], prev)
else: