The Problem seems to be in your function, as foo is of type foo: u32
You can see here and in your compiler result, that array indices have to be of type usize
so you could cast it to usize
as
array[foo as usize] = 9
or change your function header as
fn example(foo: usize) {