In the code below I get the error: Error: invalid type: 'tuple' for let / var yet inside gen2 it works, unless I change the type of the closure to auto.
when I uncomment discard c I get the error: unhandled exception: ccgtypes.nim(200, 17) false mapType [AssertionDefect]
let a = @['a','b',' ','z',' ',' ','k']
proc gen1(data:seq[char]):iterator =
return iterator():tuple =
for index, item in data:
yield (index, item)
proc gen2(data:iterator):iterator =
return iterator():tuple =
while true:
let (index, item) = data()
yield (index, item)
let b = gen1(a)
#let d = b()
let c = gen2(b)
#discard c()
let e = c()
#var
# index:int
# item:char
#var (index,item) = c()
return iterator(): (int, char) =
This is what you want to do.
Ah, that wasn't obvious to me. Had tried tuple[int, char] but nim nagged.
Thanks