diff options
author | Araq <rumpf_a@web.de> | 2011-06-20 01:28:41 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-06-20 01:28:41 +0200 |
commit | c3f11d1637cf8d07d06ba6032a52244d2e5eb6fb (patch) | |
tree | b666d482fecff54df7a0a9449776b467914f5af9 /tests | |
parent | 8b6f9ef5e8c1203ab7d84a727523723c068475ed (diff) | |
download | Nim-c3f11d1637cf8d07d06ba6032a52244d2e5eb6fb.tar.gz |
bugfix: invoking a generic iterator twice triggers a code gen bug (titer2)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/accept/compile/titer2.nim | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/accept/compile/titer2.nim b/tests/accept/compile/titer2.nim index 19c7298b0..dab2713e8 100644 --- a/tests/accept/compile/titer2.nim +++ b/tests/accept/compile/titer2.nim @@ -19,15 +19,15 @@ iterator mycountup(a, b: int): int = 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`. - 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: +when true: + 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 mycountup(0, high(t.data)): + var k = t.data[h].key + if t.data[h].slot == seFilled: yield (k, t.data[h].val) +else: + iterator pairs*(t: TTable[int, string]): tuple[key: int, val: string] = + ## iterates over any (key, value) pair in the table `t`. 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) |