Skip to content

tuple unpacking does not work in iterator #1575

@blackmius

Description

@blackmius
import std / syncio
let a = [(10, 'a'), (20, 'b'), (30, 'c')]

iterator pairs*[IX, T](a: array[IX, T]): tuple[key: IX, val: T] =
  var i = low(a)
  echo "hellow"
  while i.int < high(a).int:
    yield (i, a[i])
    i = IX(i.int + 1)

for i, (x, c) in a:
  echo i, c

test.nim(12, 18) Trace: instantiation from here
test.nim(8, 12) Error: type mismatch: got: 0..2 but wanted: 0..2
test.nim(12, 18) Trace: instantiation from here
test.nim(9, 11) Error: type mismatch: got: 0..2 but wanted: 0..2

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions