Barton,
Maxima is behaving exactly as it should. When you declare something
to be a float, Maxima is free to assume it is a float without any
further checking. If it is not a float, errors will result, in
exactly the way you are seeing in both interpreted and compiled code.
The correct way to write your 'f' function is:
> f(xp):=(modedeclare(x,float),x:float(xp),x^2);
-s