diff options
author | Araq <rumpf_a@web.de> | 2011-06-19 15:47:10 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-06-19 15:47:10 +0200 |
commit | 18bec94e2265a33ebf9834b1d73c863a3cf5ca45 (patch) | |
tree | 6530d5da994c5c9425a94115d91a4f79330f76c1 /tests/accept/compile | |
parent | 849208d779e860230bb8682b3b356ba2942dd889 (diff) | |
download | Nim-18bec94e2265a33ebf9834b1d73c863a3cf5ca45.tar.gz |
bugfix: typeinfo generation for tuples
Diffstat (limited to 'tests/accept/compile')
-rw-r--r-- | tests/accept/compile/titer2.nim | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/tests/accept/compile/titer2.nim b/tests/accept/compile/titer2.nim index 878ddf5e3..19c7298b0 100644 --- a/tests/accept/compile/titer2.nim +++ b/tests/accept/compile/titer2.nim @@ -13,13 +13,24 @@ type data: TKeyValuePairSeq[A, B] counter: int -proc len*[A, B](t: TTable[A, B]): int = - result = t.counter +iterator mycountup(a, b: int): int = + var res = a + while res <= b: + yield res + inc(res) iterator pairs*[A, B](t: TTable[A, B]): tuple[key: A, val: B] = ## iterates over any (key, value) pair in the table `t`. - for h in 0..high(t.data): - if t.data[h].slot == seFilled: yield (t.data[h].key, t.data[h].val) + var h = 0 + while h <= high(t.data): + var k = t.data[h].key + if t.data[h].slot == seFilled: yield (k, t.data[h].val) + inc(h) + + when false: + for h in mycountup(0, high(t.data)): + var k = t.data[h].key + if t.data[h].slot == seFilled: yield (k, t.data[h].val) proc initTable*[A, B](initialSize=64): TTable[A, B] = ## creates a new hash table that is empty. `initialSize` needs to be |