summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-06-20 01:28:41 +0200
committerAraq <rumpf_a@web.de>2011-06-20 01:28:41 +0200
commitc3f11d1637cf8d07d06ba6032a52244d2e5eb6fb (patch)
treeb666d482fecff54df7a0a9449776b467914f5af9 /tests
parent8b6f9ef5e8c1203ab7d84a727523723c068475ed (diff)
downloadNim-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.nim18
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)