From c3f11d1637cf8d07d06ba6032a52244d2e5eb6fb Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 20 Jun 2011 01:28:41 +0200 Subject: bugfix: invoking a generic iterator twice triggers a code gen bug (titer2) --- tests/accept/compile/titer2.nim | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'tests') 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) -- cgit 1.4.1-2-gfad0