Skip to content

bug: Tuple type inference fails with iter.enumerate() #7155

@julio4

Description

@julio4

This should be possible:

for (key, value) in array![0, 1, 2].into_iter().enumerate() {
    assert_eq!(key, value);
}

// Or:
let mut iter = array![0, 1, 2].into_iter().enumerate();
while let Option::Some((k, v)) = iter.next() {
    assert_eq!(k, v);
}

But fails with:

error: Unexpected type for tuple pattern. "?125" is not a tuple.
    for (key, value) in array![0, 1, 2].into_iter().enumerate() {
        ^^^^^^^^^^^^

However this works fine:

for (key, value) in array![(0, 0), (1, 1), (2, 2)].into_iter() {
    assert_eq!(key, value);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions