This snippet doesn't work:
arr := []; arr[0] := 1; // Error: outofbound
because the parser checks whether arr[0] exists before the assignment. Instead, you have to specify the array size when you initialize the array, so this will work:
arr := [ 'foo' ]; arr[0] := 1;
I think we should either:
- Not check whether the array element exists in assignments (this should be trivial in the new parser, which distinguishes INDEX_ASSIGNMENT and ARRAY_INDEX, but it might be harder in the old one)
- Keep checking, but create an empty element on the fly if it doesn't already exist
Unsure what the best approach would be (they might well be equivalent, given how simple the filter language is).