diff options
author | Zahary Karadjov <zahary@gmail.com> | 2014-03-05 01:14:37 +0200 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2014-03-05 02:23:53 +0200 |
commit | 5324c9ebba1aa21c893db03c1d56d3ce1b42f162 (patch) | |
tree | e800cefb7f6ee456bfa19c1dd5e6004131c23ed1 /compiler/semstmts.nim | |
parent | 016492375f149a0e71239845d55f8771e151299c (diff) | |
download | Nim-5324c9ebba1aa21c893db03c1d56d3ce1b42f162.tar.gz |
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.
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r-- | compiler/semstmts.nim | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index c8d9e353a..b11f45b38 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -616,7 +616,8 @@ proc symForVar(c: PContext, n: PNode): PSym = proc semForVars(c: PContext, n: PNode): PNode = result = n var length = sonsLen(n) - var iter = skipTypes(n.sons[length-2].typ, {tyGenericInst}) + let iterBase = n.sons[length-2].typ.skipTypes({tyIter}) + var iter = skipTypes(iterBase, {tyGenericInst}) # length == 3 means that there is one for loop variable # and thus no tuple unpacking: if iter.kind != tyTuple or length == 3: @@ -626,7 +627,7 @@ proc semForVars(c: PContext, n: PNode): PNode = # BUGFIX: don't use `iter` here as that would strip away # the ``tyGenericInst``! See ``tests/compile/tgeneric.nim`` # for an example: - v.typ = n.sons[length-2].typ + v.typ = iterBase n.sons[0] = newSymNode(v) if sfGenSym notin v.flags: addForVarDecl(c, v) else: |