This is expected behaviour, surely?

You've attempted to declare the same global variable twice - once implicitly by assigning a value and once explicitly by using "global".

The only real surprise is that the explicit declaration does not produce an error - note, if you have SetOption("Explicit","ON") then duplicate declarations do produce an error - another good reason for always setting the option.

When you use "Dim" to create the array you are not using the same variable - you are creating a new variable in the local scope.

The local variable will of course hide the global variable, so it will appear to have "worked".

This scriptlet shows what I mean:
Code:
; Create an instance of $array in the global scope

$var = 1

; Now create an instance of $array in the local scope. This will hide the
; global instance.
dim $var[10]

"In local scope the variable is "+VarTypeName($var)+@CRLF
foo()

Function foo()
"In global scope the variable is "+VarTypeName($var)+@CRLF
EndFunction



If you want to convert the global to an array, you will need to use ReDim, or assign it from a function return value.

So long as you haven't create a local scope version of the variable, the following will work for you:
Code:
$array = 1

ReDim $array[10]
? ubound($array)