While writing https://gerrit.wikimedia.org/r/#/c/443217/ I found out some wild syntax that drives the parser mad. Here are three cases, try them in debugging tools:
Write: a := [1,2,] Result: Valid syntax. This isn't a big deal, but shouldn't happen anyway. Also, the created array is actually [1,2], not [1,2,null], so no reason to allow it.Trailing commas may actually be usefulWrite: a := [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]; lcase(a[1][2 ) Result: Bye bye. The parser enters some infinite loop and the spinner keeps running like it happened in T134124.Sorry, this was due to some debugging line I left in the code.- Write: added_lines[1] = 5 Result: The exception raised is unrecognisedvariable. Since when checking syntax we don't have added_lines, I'm not sure about what should happen, but either we treat it as valid syntax (probably the best bet, since added_lines will likely be an array at runtime) or throw the notarray exception.
Update: So, the only problem here is point 3. I looked at it, and it's not trivial: if we decide to forgive the syntax, other exceptions are thrown, the last ones being in doLevelArrayElements, where we don't have enough context to determine whether we should let the syntax pass. I'll try again, but probably a more stable solution could be to clearly distinguish between really NULL variables and variables not yet computed.