-
Notifications
You must be signed in to change notification settings - Fork 12
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
Indefinite Array in Struct Fails on Access #53
Comments
Hi. For declaring a variable with an array type I used "&[i32]" rather than "[i32]". Hope this helps. |
@FanyuYe Where? In the struct definition? That leads to |
This is because you try to assign value to it. So you have to declare it use 'mut' key word. |
struct CS {
sizes : [i32 * 3],
count : i32,
}
let cache_sizes = CS {sizes: [32*1024, 256*1024, 20*1024*1024], count: 3}; // in bytes
for i in range(0, cache_sizes.count) {
print_int(cache_sizes.sizes(i));
} Writing to
struct CS {
sizes : &[i32],
count : i32,
}
let cache_sizes = CS {sizes: [32*1024, 256*1024, 20*1024*1024], count: 3}; // in bytes
for i in range(0, cache_sizes.count) {
print_int(cache_sizes.sizes(i));
} Writing to |
The latter does not work here (also not with making cache_size mutable), the first I already had as a work-around. |
It is not a big issue, just an annoyance. |
Originally, the idea was to support variable length arrays and flexible array members as in C99. But this has never been thoroughly implemented. Also, we'd like to change a couple of things how anydsl handles arrays in future versions anyway. |
Sounds good, would have saved me some time ;) |
Can I close this bug with the last commit? |
Works for me. Thanks |
When compiling the following code with impala (2ab3ab4)
Impala fails with the following message:
I don't see the cast here and the same code works if sizes and count are not in a struct but two local variables.
The text was updated successfully, but these errors were encountered: