alliedmodders/sourcemod — pull request #186 by dvander (2014-11-08 06:58:28+00:00)
Title: Define post-fix arrays as determinate and pre-fix arrays as indeterminate.

This patch gives meaning to the position of brackets in relation to an array declaration's type and name. The idea is to disambiguate determinate (fixed-length arrays) and indeterminate arrays, so future versions of SourcePawn can build extensible array types.

Prefix order, for example `int[] x`, must be an indeterminate array. To make this absolutely clear, a fixed-array literal can no longer be assigned to an indeterminate array. In the future we'll lax this restriction, once more code is using correct transitional syntax.

Postfix order, for example `int x[10]`, we now require either a fixed-length initializer or constant sizes on all dimensions. Therefore, `char x[];` or `char x[MaxClients]` are no longer valid, as those arrays are indeterminate. There is a stupid loophole here, in that something like `{ {1}, {1, 2} }` leaves the second dimension of an array indeterminate. Thus, we do not specify that all ranks must be determinate - just that if they're not, it's because there was a fixed-array initializer.

This patch introduces two new deficiencies in new-style syntax. First, a common pattern for optional outparams is `int[] out = {0}`, or `char[] out = ""`. We can no longer do that, since this constitutes a fixed-length initializer on a dynamic array. If we were to move the brackets, nothing would typecheck since most array types would not match `int[1]` or `char[1]`. I'll address this in a follow-up patch.

The second deficiency is that you can no longer create dynamic arrays with new-style syntax. For example, `int x[MaxClients + 1]` no longer works because this violates rule #2, and `int[MaxClients + 1] x` will not even parse. I'll address this in a follow-up patch as well.