bug: Tuple type inference fails with iter.enumerate()
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);
}
May I pick this up? Looks like an interesting problem.
@a-zmuth what do you know about the inference system? this is a rather complex problem - would really not recommend it as an "good first issue".
this basically requires introducing an actual type for numeric literals - that would have Copy and Drop, and would be implicitly the same as all existing numeric types - so it would be converted into them.
currently the issue is the fact that the .enumerate() result is not fully aware that it is an iterator when .into_iter() is called on it (which happens implicitly by the for) - so at some point it guesses the underlying type of the numeric literal as a felt252 - and then the inference fails.
May I try? Might take longer as I'm first time contributor, but I'm interested and have a good track record!
I think it is less relevant a a first time contributor - and we are already on it.
Hi, I am proficient Blockchain developer expert in Cairo , Rust and Solidity and also in web development. I have contributed many starknet ,stellar projects and more . please /assign Me this issue . Thank You !!
as stated in the my previous comment - we are already on it. not going to assign this to anyone out of the core-team.