Local variables not so local within block



I'm having some difficulties with a conflict between a local variable used
inside a block construct and a global variable of different type. In
particular, the conflict is between a matrix and an undeclared array.
Here is the simplest example I've found to show the problem. Indeed, the
function f is doing nothing useful, it is just an example.

(%o1) build_info();

Maxima version: 5.24.0
Maxima build date: 10:27 5/17/2011
Host type: i686-pc-linux-gnu
Lisp implementation type: GNU Common Lisp (GCL)
Lisp implementation version: GCL 2.6.7

(%i2) f(x):=block([a],a:zeromatrix(2,1),a[1,1]:x);
(%o2) f(x):=block([a],a:zeromatrix(2,1),a[1,1]:x)

(%i3) f(5);
(%o3) 5

But if we define a global undeclared array with the same name of the local
matrix inside block:

(%i4) a[1]:1;
(%o4) 1

(%i5) f(5);

assignment: array a has dimension 1, but it was called by a[1,1]
#0: f(x=5)
 -- an error. To debug this try: debugmode(true);


The probem is the conflict between the last assignement inside f(x), that
is a[1,1]:x, and a definition of a global undeclared array with the same
name of the internal variable a. If a[1,1]:x is removed from f, or if the
global array is killed, the problem disappears. Global matrices and lists
are safe, I've noticed this problem only with undeclared array.

So, why a local variable can see what is outside the block?


Stefano