Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
julio4 opened this issue Jan 24, 2025 · 0 comments · May be fixed by #7161
Open

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

julio4 opened this issue Jan 24, 2025 · 0 comments · May be fixed by #7161
Labels
bug Something isn't working

Comments

@julio4
Copy link
Contributor

julio4 commented Jan 24, 2025

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);
}
@julio4 julio4 added the bug Something isn't working label Jan 24, 2025
orizi added a commit that referenced this issue Jan 26, 2025
orizi added a commit that referenced this issue Jan 26, 2025
orizi added a commit that referenced this issue Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant