Some shorthand forms don’t work in places where the longer way does. The message says which form and shows the longer way to write it.
int32 is a storage type: arithmetic on it produces an int, never another int32, so the shorthand that would store the result straight back isn’t available:
mut x: int32 = 5 to int32;x += 1; // not supported on int32Write the arithmetic out and convert the result back yourself:
x = (x + 1) to int32;The same applies to x++ and x-- on an int32.
Compound assignment through an operator[] that you defined (grid[i] += 1) isn’t supported either. Write the read and the write out explicitly:
grid[i] = grid[i] + 1;Indexing something that can’t be indexed is the same error: [ ] works on arrays, strings, pointers, references (&T), and on a type that defines an operator []. A &?T that may be null is checked and converted to a &T first. Anything else, such as an int, has no positions to look at:
mut n: int = 3;return n[0]; // an int has no [0]If you meant to look inside a type of your own, give it an operator []:
operator [](b: Box, i: int): int { return b.value + i;}Reading through a type that only has operator []= is the same error. The setter lets you write box[0] = 5, but a read needs the getter:
return box[0]; // IntBox declares operator []=, not operator []Declare operator [] as well. A getter that takes a different index type than the one you passed (“No ‘operator[]’ overload matches”) is reported separately; the index type must match exactly.
void has no size, so sizeof(void) isn’t supported. Use sizeof(void*) for the size of a pointer, or the size of the type you actually mean:
malloc(sizeof(void)); // not supportedmalloc(sizeof(int)); // fineRun turf --explain E126 in a terminal to read this again.